Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

<Update: Root Node has been revised since this was posted /update>

Let me repeat: web pages do NOT have intrinsic page breaks. When printed to dead trees, the print routine inserts them, but when viewed on a monitor they have no need to paginate.

Think of the rendered web page as appearing on a long (very long!) roll of paper, with each end attached to a roller, viewed through a window frame. Scrolling moves the paper (use "vertically" for your mental model); changes which portion of the text you can see. Web pages are NOT analagous to cut sheets of paper, be those 8.5x11, A4, Legal, or 6 inches wide by a mile high.

So, assuming your "nicely formatted text files" are, indeed, pure text and not some form of word-processing format, you need do no more than this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http:/ +/"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> (provide a title) </title> <meta name="description" content="##provide a narrative description of + the content##"> <meta name="keywords" content="##provide keywords (or phrases, enclose +d in single quotes) separated by commas##"> </head> <body> <pre> **Insert your "nicely formatted text" here assuming that "nicely forma +tted" means line_length not too much more than 80 chars; while many m +onitors are much wider, aim for the lowest common denominator.** <pre> </body> </html>

You can practically use the content above as an element of a home-brew templating system. The step-by-step below is sub-optimal, but should work until you learn more about html, perl, and the templating systems cited in previous responses.

  1. Save the template above to a local file.
  2. Read (see open among others) the template into a variable in your script).
  3. Read the "nicely formatted text" into another variable.
  4. Use substitution (see perlretut) on the first variable to replace the content above between ** and ** with the contents of your second variable.
  5. Hand tweak the <meta....>s above, replacing the ##...## with appropriate content, or remove them before step one if you're not worried about search engine rankings.
  6. Write (see"open" above and perldoc -f print) the modified second variable to a file, name.htm.
  7. Move or copy the name.htm to a web server (if some viewers will be on-line) or simply distribute it to interested parties as an attachment to email, by sneaker net or whatever.

There will be no page breaks. And, FWIW, you can simply paste (remember, we're assuming your source files are truly pure "text," not word processor documents, .pdfs, Latex, or some other format using markup) the source document into an email to distribute it. Same deal: no page breaks.

If, however, your source file is a wp document, note that wp documents do, typically, contain page break codes. You may have to remove those. But you will also have a strip whatever markup the creator_application inserted to organize the tables and then recreate those with .html or even .xml markup (for which, you'll need to spend a few minutes learning the fundamentals).

In reply to Re^3: Supressing page breaks in forms by ww
in thread Supressing page breaks in format/write output by yaconsult

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-07-06 13:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found