Author: mcbrown
Date: 2006-09-05 14:29:42 +0200 (Tue, 05 Sep 2006)
New Revision: 3233
Log:
Adding two new conversions for Stefan's FrameMaker formatting script
Modified:
trunk/tools/format-framemaker.pl
Modified: trunk/tools/format-framemaker.pl
===================================================================
--- trunk/tools/format-framemaker.pl 2006-09-05 12:11:18 UTC (rev 3232)
+++ trunk/tools/format-framemaker.pl 2006-09-05 12:29:42 UTC (rev 3233)
Changed blocks: 3, Lines Added: 40, Lines Deleted: 5; 2329 bytes
@@ -1,13 +1,25 @@
#!/usr/bin/perl -w
-# formatlistingsCRLF.pl - reformats the line endings in <programlisting>
-# to include the special character sequence !!CRLF!!; used for converting
-# our DocBook XML into a format that can be used within FrameMaker, which
-# otherwise ignores line endings
+# formatlistingsCRLF.pl - reformats the DocBook document into a format
+# suitable for FrameMaker.
#
+# Performs the following conversions:
+
+# 1) Translates the line endings in <programlisting> to include the
+# special character sequence !!CRLF!!; used for converting
+# our DocBook XML into a format that can be used within FrameMaker,
+# which otherwise ignores line endings
+#
+# 2) Converts <ulink url="URL"/> into <ulink url="URL">URL</ulink>
+#
+# 3) Translates leading spaces in programlistings to '!!space!!'
+#
# Martin MC Brown
# mc@stripped
# 2006-09-03
+#
+# 2006-09-05
+# Additional changes to the script functionality (parts 2 and 3)
use utf8;
use IO::File;
@@ -20,7 +32,7 @@
my $source = IO::File->new($src,'r');
binmode($source,':utf8');
my $dest = IO::File->new($dst,'w');
-binmode($dest,':utf8)');
+binmode($dest,':utf8');
my $inpl = 0;
@@ -30,8 +42,31 @@
$inpl = 1 if ($line =~ m/<programlisting/);
$inpl = 0 if ($line =~ m{</programlisting>});
+ if ($line =~ m/<ulink url=".*?"\/>/)
+ {
+ $line =~ s/<ulink url="(.*?)"\/>/<ulink url="$1">$1<\/ulink>/g;
+ }
+
if ($inpl)
{
+ if ($line =~ m/<programlisting/)
+ {
+ my ($space) = ($line =~ m/<programlisting>(\s+)\S/);
+ if (defined($space))
+ {
+ my $replspace = '!!space!!' x length($space);
+ $line =~ s/<programlisting>($space)/<programlisting>$replspace/;
+ }
+ }
+ else
+ {
+ my ($space) = ($line =~ m/^(\s+)\S/);
+ if (defined($space))
+ {
+ my $replspace = '!!space!!' x length($space);
+ $line =~ s/^($space)/$replspace/;
+ }
+ }
print $dest Encode::encode("utf8","$line!!CRLF!!\r\n");
}
else
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r3233 - trunk/tools | mcbrown | 5 Sep |