Not changing whitespace in certain elements

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Not changing whitespace in certain elements

Warren Block
FreeBSD uses tidy to clean up DocBook-generated HTML.  For example,
   tidy -wrap 90 -m -raw -preserve -f /dev/null -asxml  book.html

But some of the output is from <programlisting> elements, which may
contain tabs that should be kept verbatim.  Here's a pre-tidy example
with added line numbers:

  1  <PRE
  2  CLASS="PROGRAMLISTING"
  3  ><TT
  4  CLASS="FILENAME"
  5  >sys/boot/i386/boot2/Makefile:</TT
  6  >
  7  boot2: boot2.ldr boot2.bin ${BTX}/btx/btx
  8          btxld -v -E ${ORG2} -f bin -b ${BTX}/btx/btx -l boot2.ldr \
  9                  -o boot2.ld -P 1 boot2.bin</PRE
10  ><P
11  >

Line 8 starts with a tab, and line 9 starts with two tabs.  This
particular example is from a Makefile, where tabs are significant.  Left
alone, the text can be copied from the browser, and the tabs are obvious
from the highlighting.  But tidy replaces the tabs with spaces.

Is there a way to get tidy to leave whitespace alone inside this class
of <pre> elements?

Thanks!


Reply | Threaded
Open this post in threaded view
|

Re: Not changing whitespace in certain elements

Bjoern Hoehrmann
* Warren Block wrote:
>Line 8 starts with a tab, and line 9 starts with two tabs.  This
>particular example is from a Makefile, where tabs are significant.  Left
>alone, the text can be copied from the browser, and the tabs are obvious
>from the highlighting.  But tidy replaces the tabs with spaces.
>
>Is there a way to get tidy to leave whitespace alone inside this class
>of <pre> elements?

Tidy should never generate tabs (and you are not supposed to use them
per the HTML 4 Recommendation inside <pre> elements). Not changing the
white space is a bit difficult while also pretty printing the document,
and it is likely that the code makes various assumptions about cleanup
with respect to white spaces that would probably make this difficult to
implement, especially if this is supposed to preserve tabs.
--
Björn Höhrmann · mailto:[hidden email] · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/