[debian-edu-commits] debian-edu/ 02/02: Adjust convert script to handle < and > better, as well as handle footnotes in tables.

Petter Reinholdtsen pere at moszumanska.debian.org
Fri Oct 2 15:57:23 UTC 2015


This is an automated email from the git hooks/post-receive script.

pere pushed a commit to branch master
in repository debian-edu-itil-doc-nb.

commit b4d218f146143dd3657c77e9f5b7a50aaadc77c2
Author: Petter Reinholdtsen <pere at hungry.com>
Date:   Fri Oct 2 17:57:15 2015 +0200

    Adjust convert script to handle < and > better, as well as handle footnotes in tables.
---
 documentation/itil/convert.pl | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/documentation/itil/convert.pl b/documentation/itil/convert.pl
index 433eb2e..cf59cc4 100755
--- a/documentation/itil/convert.pl
+++ b/documentation/itil/convert.pl
@@ -58,6 +58,16 @@ sub o_list {
 	return 1;
 }
 
+# Filtering that should take place both inside and outside tables
+sub filter_line {
+	my $line = shift;
+	# Footnotes have completely different notation
+	$line =~ s%<ref>%<<FootNote(%g;
+	$line =~ s%</ref>%)>>%g;
+	$line =~ s%<references */>%%g;
+	return $line;
+}
+
 ## A very primitive approach to table conversion,
 ## but it should work for pandoc output.
 sub we_can_has_tables {
@@ -72,11 +82,11 @@ sub we_can_has_tables {
 			print "||\n";
 			return;
 		} elsif (substr($line, 0, 1) eq '!') {
-			print "||" . substr($line, 1);
+			print "||" . substr(filter_line($line), 1);
 		} elsif (substr($line, 0, 1) eq '|') {
-			print "||" . substr($line, 1);
+			print "||" . substr(filter_line($line), 1);
 		} else {
-			print $line;
+			print filter_line($line);
 		}
 	}
 }
@@ -94,11 +104,6 @@ while (($line = <$fh>)) {
 	$line =~ s%<code>%`%g;
 	$line =~ s%</code>%`%g;
 
-	# Footnotes have completely different notation
-	$line =~ s%<ref>%<<FootNote(%g;
-	$line =~ s%</ref>%)>>%g;
-	$line =~ s%<references */>%%g;
-
 	# Avoid turning camelcase text into links
 	$line =~ s%(\b[A-Z]+[a-z]+[A-Z]+\S*\b)%!$1%g;
 
@@ -112,6 +117,11 @@ while (($line = <$fh>)) {
 		we_can_has_tables $line;
 		next;
 	}
+	$line = filter_line($line);
+
+	# <> can be used directly
+	$line =~ s%<%<%g;
+	$line =~ s%>%>%g;
 
 	print $line . "\n";
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-edu/upstream/debian-edu-itil-doc-nb.git



More information about the debian-edu-commits mailing list