Tidy and HTML tab spacing

Hiroki Sato hrs at FreeBSD.org
Thu Jan 19 06:59:31 UTC 2012


Warren Block <wblock at wonkity.com> wrote
  in <alpine.BSF.2.00.1201181748230.42380 at wonkity.com>:

wb> > I think this will break the results because a newline just after ">"
wb> > is recognized as CDATA.
wb>
wb> A test run on the Porter's Handbook did seem to work:
wb>   make -C /usr/ports/www/tidy-devel deinstall
wb>   make clean book.html
wb>   perl -0777 -i -pe
wb>   's/CLASS="PROGRAMLISTING"\n\>/CLASS="PROGRAMLISTING"\>\n/g' book.html
wb>   make -C /usr/ports/www/tidy-devel install clean
wb>   tidy -wrap 90 -m -raw -preserve -f /dev/null -asxml  book.html

 Yes, but this just covers the issue because column calculation by
 Tidy is based on literals in the markup text, not on the result text.
 For example, in the following line

>[tab]foo

 Tidy expands [tab] to spaces based on the length of ">[tab]foo"
 regardless of the fact that ">" is not a character in the result
 text.  So, if we convert this into two line like the following:

>
[tab]foo

 the expansion of the [tab] will be correct.  However, this trick does
 not always work as intended.  One is that \n just after ">" means a
 newline in <pre>, not automatically ignored.  So, all of
 <programlisting> will have a empty line at the top.  Another is that
 this is valid only for a particular case.  For example:

<programlisting>foo[tab]<emphasis>bar</emphasis>[tab]baz
foo[tab]bar[tab]baz</programlisting>

 The <emphasis> will be converted to <span> in the HTML output and two
 lines of "foo bat baz" will not be aligned because Tidy counts the
 <span> tag for the tab expansion.  This cannot solve by converting
 "\n>" to ">\n" at the end of a <pre> tag in the HTML output.

 It is difficult to solve this issue completely because the result
 text can be obtained only by a complete HTML processor such as www
 browsers.  I don't have a good idea, but I think it is not a bad idea
 to use a tab character (or replacing it to 	) in the result text
 by modifying Tidy and leave the processing to www browsers.

-- Hiroki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-doc/attachments/20120119/f6f46dce/attachment.sig>


More information about the freebsd-doc mailing list