Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Today I decided to learn more about the Template-Toolkit. I am the kind of person that can learn the first steps better when I read things on paper. Reading from screen is fine for me for looking up a reference, but reading long texts is a pain. Regardless if it is a CRT or a TFT display.

The docs of Template Toolkit are, as of many Perl modules, splitted in many small chunks, which is also fine for reference, but a pain to print out.

So I decided to put the stuff together in a Word (/me ducks) file and make a pdf out of it, so i can share it with people. I planned to make it in three parts.
  • The Manual
  • The Tutorial
  • The Reference
The manual and the tutorial consist of a few documents so i did them by hand. I copied the relevant parts from the HTML-doc and inserted them into Word, changed headings, inserted pagebreaks, did some pageformatting and printed it to a pdf.

So far so good. But when I came to the reference I realized that there are far too many files to do it conviniently by hand. Solution: script it.

Here is the script I used for the issue. It uses regexes to deal with the html, but since Active States HTML-Docs are computer generated I think that is ok in this case :-D
my @f = ( "c:/perl/html/site/lib/Template.html", "c:/perl/html/site/lib/Template/Base.html", #... "c:/perl/html/site/lib/Template/Plugin/XML/Style.html", "c:/perl/html/site/lib/Template/Plugin/XML/XPath.html", ); open OUT, ">ref.html"; print OUT <<"HTML"; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w +3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Template::Config - Factory module for instantiating other TT2 m +odules</title> <link rel="stylesheet" href="Active.css" type="text/css" /> <link rev="made" href="mailto:" /> </head> <body> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" valign="middle"> <big><strong><span class="block">&nbsp;Template::Config - Factory modu +le for instantiating other TT2 modules</span></strong></big> </td></tr> </table> <p> HTML for my $f ( @f ) { #trigger $i=0; open IN, $f or die "$f: $!"; while ( <IN> ) { $i=1 if /<!-- INDEX END -->/; $i=0 if /<h1><a name="authors?">/; #tweak the NAME heading my $ff = $f; $ff =~ s/^.+Template/Template/; $ff =~ s/\.html//; $ff =~ s/\//::/g; s/<h1><a name="name">NAME<\/a><\/h1>/[[[PB!]]]<h0><a name="nam +e">$ff<\/h0>/; s/<hr \/>//g; #tweak headings one step smaller s/(<\/?h)([0-9])(>)/$1.($2+1).$3/eg; print OUT $_ if $i; } } print OUT "</body></html>";
That worked fine. All I had to do manually was replacing the [[[PB!]]] parts with pagebreaks using the "search and replace" functionality of Word, formatting the pages and adding a autogenerated Table of Contents. Et voila, a full fledged book. :-)

As you may have noticed, the html relies on a external stylesheet, so you can even tweak the formatting to you your liking.

I will put the six Files (TT-Manual-Single, TT-Manual-Double, TT-Tutorial-Single, TT-Tutorial-Double, TT-Reference-Single and TT-Reference-Double) on my webspace at holli.perlmonk.org as soon as I get home, since I cannot ssh from work.

The difference between "Double" and "Single" here is that one is optimized for double paged print, the other for single page print.

Update:
The files are now available at http://holli.perlmonk.org/TTdocs. There is a 20MB transfer limit per day on jcwren's server, so please be kind if it does not work for you. Just try the other day.


holli, /regexed monk/

In reply to Turning HtmlDoc into Book by holli

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-25 08:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found