#!/usr/bin/perl # # Tested with # # $ ./proctut.pl tutorial.html > foo && diff foo tutorial.html | head -20 # # BTW, tutorial.html is from: # # http://www.geda.seul.org/docs/current/tutorials/gsch2pcb/tutorial.html # # # Alternatively, # # http://diberri.dyndns.org/wikipedia/html2wiki/ # # might do everything I was hoping this script would do. # # # I just did (as wpd): # # $ perl -MCPAN -e 'install Bundle::HTMLWikiConverter' # # to install it, but I'm not sure it worked. # # # I tried again, but it still looks like it didn't work. Eventually I # installed it as root, was able to run it, wasn't too happy with the # results, and wasn't confident of my ability to change the script. So # now I'm back here. # # As of 05/03/07, I've been running this as: # # $ ./proctut.pl < tutorial.html > tutorial.wpd # # And looking at, and sometimes uploading, the results. # use strict; my $list_indent = 0; my @list_char_stack; my $list_char = ""; my $list_item = 0; my $in_href = 0; my $in_code = 0; while (<>) { next if /^/; # skip the ... header line */ s/>/>/g; # Replaces ">" with ">" s/</>/g; # Replaces "<" with "<" s/<\/?(center|blockquote)>//g; # Get rid of
and
# and
pairs s/<\/?(table|tbody|tr|td).*>//g; # Get rid of table related stuff # and
pairs s/

(.*)<\/h2>/====== \1 ======/g; # Change

lines to headline level 1 s/

(.*)<\/h3>/===== \1 =====/g; # Change

lines to headline level 2 s/

(.*)<\/h4>/==== \1 ====/g; # Change

lines to headline level 3 s/

(.*)<\/h5>/**\1**/g; # Bill appears to use
to mean "Bold", # At least that's the way it's rendered # in my browswer for the one place he # he used it. s/(.*?)<\/b>/**\1**/g; # Change ... tags s//----/g; # horizontal line s/(.*)<\/i>/\/\/\1\/\//g; # Change ...<\i> to //...// # Gee, that was fun with all of the escape # characters! s//{{wiki:\1}}/g; # Deal with embedded images s/<\/p>//; # Get rid of

next if /^\s*$/; # skip blank lines s/
/\\\\\n/; # Change
to forced linebreak (\\\n) s/^\s+//; # Compress whitespace at the beginning of # a line. if (s/