summaryrefslogtreecommitdiff
path: root/Docs/Support/colspec-fix.pl
diff options
context:
space:
mode:
authorunknown <zak@linux.local>2002-02-27 06:47:14 -0700
committerunknown <zak@linux.local>2002-02-27 06:47:14 -0700
commitbbfdc6ee5af516247f2526cf875d51395cd5384c (patch)
treed0a11edc2587672673fe796947e6eadc28184e0c /Docs/Support/colspec-fix.pl
parent633d54b67e577ea1ac1cf845f1367c2d9e7f06d1 (diff)
downloadmariadb-git-bbfdc6ee5af516247f2526cf875d51395cd5384c.tar.gz
colspec-fix.pl:
Script that takes the relative values in the colspec tags and converts them to absolute values.
Diffstat (limited to 'Docs/Support/colspec-fix.pl')
-rwxr-xr-xDocs/Support/colspec-fix.pl50
1 files changed, 50 insertions, 0 deletions
diff --git a/Docs/Support/colspec-fix.pl b/Docs/Support/colspec-fix.pl
new file mode 100755
index 00000000000..48913d6d638
--- /dev/null
+++ b/Docs/Support/colspec-fix.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/perl -w
+
+#
+# Script to rewrite colspecs from relative values to absolute values
+#
+
+use strict;
+
+my $table_width = 12.75; # cm
+my $gutter_width = 0.09; # cm
+
+my $str = join '', <>;
+
+$str =~ s{([\t ]*(<colspec colwidth=\".+?\" />\s*)+)}
+ {&rel2abs($1)}ges;
+
+print STDOUT $str;
+exit;
+
+#
+# Definitions for helper sub-routines
+#
+
+sub msg {
+ print STDERR shift, "\n";
+}
+
+sub rel2abs {
+ my $str = shift;
+
+ my @widths = ();
+ my $total = 0;
+ my $output = '';
+
+ $str =~ /^(\s+)/;
+ my $ws = $1;
+
+ while ($str =~ m/<colspec colwidth="(\d+)\*" \/>/g) {
+ $total += $1;
+ push @widths, $1;
+ }
+
+ my $unit = ($table_width - ($#widths * $gutter_width)) / ($total);
+
+ foreach (@widths) {
+ $output .= $ws . '<colspec colwidth="'. sprintf ("%0.2f", $_ * $unit) .'" />' . "\n";
+ }
+
+ return $output . "\n$ws";
+}