Commit patch to not break on spaces.
[bowtie.git] / doc / strip_markdown.pl
1 #!/usr/bin/perl -w
2
3 # Used to convert MANUAL.markdown to MANUAL.
4
5 use strict;
6 use warnings;
7
8 my $lastBlank = 0;
9
10 while(<>) {
11         # Skip comments
12         next if /^\s*<!--/;
13         next if /^\s*!/;
14         next if /^\s*-->/;
15         # Skip internal links
16         next if /\[.*\]: #/;
17         # Skip HTML
18         next if /^\s?\s?\s?<.*>\s*$/;
19         # Skip HTML
20         next if /^\s*<table/;
21         next if /^\s*<\/td/;
22         # Strip [`...`]
23         s/\[`/`/g;
24         s/`\]/`/g;
25         # Strip [#...]
26         s/\[#[^\]]*\]//g;
27         # Strip (#...)
28         s/\(#[^\)]*\)//g;
29         # Turn hashes into spaces
30         s/^####/   /;
31         s/^###/ /;
32         if(/^\s*$/) {
33                 next if $lastBlank;
34                 $lastBlank = 1;
35         } else {
36                 $lastBlank = 0;
37         }
38         print $_;
39 }