File: strip_markdown.pl

package info (click to toggle)
centrifuge 1.0.3-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,028 kB
  • sloc: cpp: 51,936; perl: 1,919; python: 1,538; makefile: 621; sh: 373
file content (45 lines) | stat: -rw-r--r-- 778 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env perl -w

##
# strip_markdown.pl
#
# Used to convert MANUAL.markdown to MANUAL.  Leaves all manual content, but
# strips away some of the clutter that makes it hard to read the markdown.
#

use strict;
use warnings;

my $lastBlank = 0;

while(<>) {
	# Skip comments
	next if /^\s*<!--/;
	next if /^\s*!/;
	next if /^\s*-->/;
	# Skip internal links
	next if /\[.*\]: #/;
	# Skip HTML
	next if /^\s?\s?\s?<.*>\s*$/;
	# Skip HTML
	next if /^\s*<table/;
	next if /^\s*<\/td/;
	next if /^\s*<.*>\s*$/;
	# Strip [`...`]
	s/\[`/`/g;
	s/`\]/`/g;
	# Strip [#...]
	#s/\[#[^\]]*\]//g;
	# Strip (#...)
	s/\(#[^\)]*\)//g;
	# Turn hashes into spaces
	#s/^####/   /;
	#s/^###/ /;
	if(/^\s*$/) {
		next if $lastBlank;
		$lastBlank = 1;
	} else {
		$lastBlank = 0;
	}
	print $_;
}