-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDL2: Convert a bunch of MediaWiki tables to Markdown format.
This is the perl script that did it: ```perl use warnings; use strict; while (<>) { chomp; print("$_\n"), next if not /\A\{\|/; #next if not /\A\{\|/; # Convert mediawiki table... my $row = 0; my $col = 0; my @A = (); while (<>) { chomp; my $l = $_; if (/\A\|\-/) { $row++; $col = 0; } elsif (/\A\|\}/) { $row++; last; } else { $l =~ s/\A\|//; #print("\$a[$row][$col] = '$l'\n"); push @A, $l; $col++; } } #print("------row=$row, col=$col\n\n\n"); my @lengths = (); for (my $c = 0; $c < $col; $c++) { my $len = 0; for (my $r = 0; $r < $row; $r++) { my $str = $a[($r * $col) + $c]; my $slen = length($str); $len = $slen if ($slen > $len); } push @lengths, $len; } print('|'); for (my $c = 0; $c < $col; $c++) { print(' ' x ($lengths[$c] + 1)); print(' |'); } print("\n"); print('|'); for (my $c = 0; $c < $col; $c++) { print(' '); print('-' x $lengths[$c]); print(' |'); } for (my $r = 0; $r < $row; $r++) { print("\n"); print('|'); for (my $c = 0; $c < $col; $c++) { my $str = $a[($r * $col) + $c]; print(' ' . substr($str . ' ' x $lengths[$c], 0, $lengths[$c])); print(' |'); } } print("\n"); } ``` ...then this shell one-liner to run that perl on each file... ```bash for x in *.md ; do echo $x ... ; ../cvttab.pl <$x >$x.tmp ; mv $x.tmp $x ; done ```
- Loading branch information
Showing
54 changed files
with
510 additions
and
1,660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.