| 1 | #!/usr/bin/perl -w |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use English; |
|---|
| 5 | |
|---|
| 6 | my $text = ""; |
|---|
| 7 | my $in_final_tables = 0; |
|---|
| 8 | while (my $line = <>) { |
|---|
| 9 | # Get rid of the URLs of external links |
|---|
| 10 | $line =~ s/\s*\[<fo:basic-link external-destination="[^"]*">[^<]*<\/fo:basic-link>\]//g; |
|---|
| 11 | # Align two-column examples. |
|---|
| 12 | $line =~ s/-4pc/-1pc/g; |
|---|
| 13 | # Ensure productions have some leading space. |
|---|
| 14 | $line =~ s/fo:table id/fo:table space-before.minimum="0.8em" space-before.optimum="1em" space-before.maximum="2em" id/; |
|---|
| 15 | # Ensure Escaped characters are separated from productions. |
|---|
| 16 | $line =~ s/^ [ ]+Escaped/ Escaped/; |
|---|
| 17 | # Ensure the production counter has enough space. |
|---|
| 18 | $line =~ s/"5%"/"10mm"/g; |
|---|
| 19 | # Expand the monospace family |
|---|
| 20 | $line =~ s/{\$monospace\.font\.family}/monospace/g; |
|---|
| 21 | # Add the special symbols to monospace. |
|---|
| 22 | $line =~ s/"monospace"/"monospace,Symbol,ZapfDingbats"/g; |
|---|
| 23 | # Convert URLs to monospace. |
|---|
| 24 | $line =~ s!(</fo:basic-link><fo:inline)!$1 font-family="monospace"!g; |
|---|
| 25 | # enforce keep-together. |
|---|
| 26 | $line =~ s/<fo:table-row/<fo:table-row keep-together="always"/g; |
|---|
| 27 | # Add margin and p[adding to preview examples. |
|---|
| 28 | $line =~ s/border-style/margin="2pt" padding="2pt" border-style/ if ($line =~ /fo:block><fo:block wrap-option/); |
|---|
| 29 | # Add margin and padding to syntax examples. |
|---|
| 30 | $line =~ s/border-style/margin="2pt" padding="2pt" border-style/ if ($line =~ /^<fo:block wrap-option/); |
|---|
| 31 | # Fix the disappearing trademark problem. |
|---|
| 32 | $line =~ s/\(YAML\)/(YAML™)/g; |
|---|
| 33 | # Break the attempt to one-line the title |
|---|
| 34 | $line =~ s|^ : $|</fo:block><fo:block>|; |
|---|
| 35 | # YAML calls "Symbols" Indicators" |
|---|
| 36 | $line =~ s/Symbols/Indicators/g; |
|---|
| 37 | # Collapse multiple spaces in index terms |
|---|
| 38 | for (my $i = 0; $i < 6; $i++) { |
|---|
| 39 | $line =~ s/key="((?:[^" ]+ )+)[ ]+/key="$1/; |
|---|
| 40 | } |
|---|
| 41 | # Get rid of the non-ASCII characters. |
|---|
| 42 | $line =~ s/\302?\240/ /g; # nbsp |
|---|
| 43 | $line =~ s/\302?\251/©/g; # copyright |
|---|
| 44 | $line =~ s/\302?\260/°/g; # deg |
|---|
| 45 | $line =~ s/\302?\267/·/g; # middot |
|---|
| 46 | $line =~ s/\303?\327/×/g; # times |
|---|
| 47 | $line =~ s/d[^ ]*t Net/döt Net/g; # ouml |
|---|
| 48 | |
|---|
| 49 | $in_final_tables++ if $line =~ /10.2.2. Resolution</; |
|---|
| 50 | $line =~ s/column-number="1"\//column-number="1" column-width="60%"\// if $in_final_tables > 1; |
|---|
| 51 | $line =~ s/column-number="2"\//column-number="2" column-width="40%"\// if $in_final_tables > 1; |
|---|
| 52 | |
|---|
| 53 | print $line; |
|---|
| 54 | } |
|---|