My wife had some large digital books she downloaded as CHM files and wanted to read in a less cumbersome format. I used extract_chmlib to generate a directory of all the HTML files and images, but the table of contents information was in a bastard-step-child of an html file with a *.hhc" extension. This was a quick and dirty strict that massaged it into an index.html file she could open in her browser
I have no idea if all CHM files contain the same kinds of table of contents files, but if they do, this might be usefull...
#!/usr/bin/perl while (my $line = <>) { $line =~ s{<OBJECT type="text/site[^"]*">}{}g; $line =~ s{</OBJECT>}{}g; $line =~ s{<param name="ImageNumber" value="\d*">}{}g; $line =~ s{<param name="Name" value="([^"]*)">}{$1}g; $line =~ s{<param name="Local" value="">}{...}g; $line =~ s{<param name="Local" value="([^"]*)">}{ <a href="$1">##< +/a>}g; $line =~ s{<param name="[^"]*" value="[^"]*">}{}g; print $line; }
Edit: Fixed the horrendously confusing spelling mistake in the Title<
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Quci and Dirty index.html generator for CHM files
by james2vegas (Chaplain) on Aug 26, 2009 at 19:13 UTC | |
by hossman (Prior) on Aug 26, 2009 at 23:01 UTC | |
by james2vegas (Chaplain) on Aug 27, 2009 at 03:50 UTC |
Back to
Cool Uses for Perl