From 870e63be7360b5a0097a27656048e853bc720464 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Jul 2014 22:29:16 -0700 Subject: Initial commit --- spec2md.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spec2md.pl (limited to 'spec2md.pl') diff --git a/spec2md.pl b/spec2md.pl new file mode 100644 index 0000000..1b4f26e --- /dev/null +++ b/spec2md.pl @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +my $stage = 0; +my $example = 0; +my @match; +my $section = ""; + +while () { + if (/^\.$/) { + if ($stage == 0) { + $example++; + print "\n
\n"; + print "
Example $example
\n\n"; + print "````````````````````````````````````````````````````````` markdown\n"; + } elsif ($stage == 1) { + print "`````````````````````````````````````````````````````````\n\n"; + print "````````````````````````````````````````````````````````` html\n"; + } elsif ($stage == 2) { + print "`````````````````````````````````````````````````````````\n\n"; + print "
\n\n"; + } else { + die "Encountered unknown stage $stage"; + } + $stage = ($stage + 1) % 3; + } else { + if ($stage == 0 && (@match = ($_ =~ /^#{1,6} *(.*)/))) { + $section = $match[0]; + } + if ($stage != 0) { + # $_ =~ s/ /␣/g; + } + print $_; + } +} -- cgit v1.2.3