diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-07-21 22:29:16 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-08-13 22:56:32 -0700 |
commit | 870e63be7360b5a0097a27656048e853bc720464 (patch) | |
tree | e8f19ee2d62e529115cb71dcda5f3298cca7d389 /spec2md.pl | |
parent | 650ad87f35f4405a2ca8270d2b2835daa442e5f1 (diff) |
Initial commit
Diffstat (limited to 'spec2md.pl')
-rw-r--r-- | spec2md.pl | 36 |
1 files changed, 36 insertions, 0 deletions
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 (<STDIN>) { + if (/^\.$/) { + if ($stage == 0) { + $example++; + print "\n<div class=\"example\" id=\"example-$example\" data-section=\"$section\">\n"; + print "<div class=\"examplenum\">Example $example</div>\n\n"; + print "````````````````````````````````````````````````````````` markdown\n"; + } elsif ($stage == 1) { + print "`````````````````````````````````````````````````````````\n\n"; + print "````````````````````````````````````````````````````````` html\n"; + } elsif ($stage == 2) { + print "`````````````````````````````````````````````````````````\n\n"; + print "</div>\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 $_; + } +} |