in reply to Re: Re: Add line numbers to HTML
in thread Add line numbers to HTML

Unless you can assure that lines don't wrap, you can't do that. However, <pre> tags are able to prevent wrapping; they preformat the text to your specifications, regardless of browser window size. That has a BIG disadvantage though. Consider someone using a screen smaller than the one for which your document was designed. The benefit of line numbering will be outweighed by the pain in the rear of having to horizontally scroll to read each line.

Nevertheless, you do see it done sometimes. See our own Craft section as an example of using <pre> tags, tables, etc., to create a formatting that is condusive to line numbering.


Dave

Replies are listed 'Best First'.
Re: Re: Re: Re: Add line numbers to HTML
by Anonymous Monk on Mar 20, 2004 at 06:48 UTC
    All points that I have also thought of, dang... Basically this was supposed to make reviewing these documents easier for big groups. Any other ideas or different approaches?
      Going off on a wild ass guess here, it sounds like you have a bunch of "reports" embedded in to html. If thats the case, you could possibly embed the report inside a specific tag, like the perlmonks <code></code> tags. Then you only have to number content in side this tag and thats hugely simpler.

      Of course you still have issues as to what exactly constitutes a line. If you do it based on new lines, you might not catch them all because thw browser will automatically wrap paragraphs in certain spots. From here you can basically implement you're own wrapping using text::wrap or something similar from cpan, or perhaps, maybe, do some strange stuff with javascript that might do what you want. But I doubt it.
      Hmm... besides the tools that Hyper-Text Markup Language already offers? ;)

      I haven't seen the documents in question, but maybe it would be appropriate to employ ordered and/or unordered lists to give an "outline" look and feel to the documents. That may not be something that you can easily automate though.


      Dave