Perl.com 
Published on Perl.com

Having Trouble Printing Code Examples?

If you're having trouble printing code examples from our pages, you're probably using a 4.x version of Netscape. You'll want to use something like Netscape 6 or MSIE to print articles that include example code.

Read on if you're interested in more about the details of this problem.

The problem comes with a Netscape 4.x issue with character entities in general, and specifically with the &lt; for < and &gt; for > entities. It's also not necessarily specific to printing.

If you view the source of a page using these character entities in Netscape 4.x, you'll see that the source view has converted them into the regular "<" and ">" symbols. If you view the source in Netscape 6 or MSIE, you'll see that they remain as they were originally entered: &lt; and &gt;.

It seems that Netscape 4.x turns the code for character entities into the character itself. While this doesn't seem to affect the display in the browser, it does affect what happens when the page is sent to the printer. Something that is coded into the article like:

&lt;script language="PHP"&gt;

is, in Netscape 4.x, presented instead as:

<script language="PHP">

and, since that doesn't display in HTML, it doesn't print either.

The same thing happens if you do a "View Source" and copy all of that HTML into a new file and then view it -- if you View Source in MSIE or Netscape 6, it's fine. But if you View Source in Netscape 4.x, and copy and paste from that, your code sample bits are going to be put in as actual code, and they won't display in any browser.

In any case, the solution is to use something other than Netscape 4.x for printing articles that include code samples.

Perl.com Compilation Copyright © 1998-2003 O'Reilly & Associates, Inc.

Return to Related Articles from the O'Reilly Network .


Library Navigation Links