forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Conal Tuohy <>
Subject [PATCH] for <source> elements that are too wide
Date Tue, 21 Oct 2003 20:26:08 GMT
Some of the pages in the Cocoon HTML-format documentation are too wide to
display on screen, or print in portrait-orientation on paper, because of
<source> elements with very long lines.

The document2html.xsl stylesheet renders <source> elements as HTML <pre>
elements, which can make the resulting pages too wide to see on screen or
print. A web page that is wider than the screen is a complete bastard to
read - you have to scroll left and right all the time. And printing in
landscape orientation is not very nice either.

The problem is:

1) Browsers usually render <pre> elements in a fixed-width font, which are
always wider than normal fonts.

2) There is no line-wrapping in a <pre> element, so a single long line of
source can make the web page very wide.

The patched stylesheet includes an extra template (and a couple of helper
templates) to render simple <source> elements (i.e. those which contain only
text content) as a <div> containing a sequence of <p> elements. The font
name itself is not specified, so it will generally be a proportional font.
The font size is reduced ("smaller"). The template uses CSS "style"
attributes to retain the original indentation while still allowing for
line-wrapping. A single space of indentation is rendered as a 4pt indent.
Where a line of source wraps, the wrapped part of the line is further
indented by 8pt (i.e. equivalent to 2 spaces). The template also attempts to
keep quoted string literals together on one line, by converting spaces
inside quotes into non-breaking spaces.

This new XSL code treats the content of the <source> element as a single
string, so the old template should be left in place to handle <source>
elements that do contain extra markup. Hence this new code is purely
additional to the existing stylesheet - it doesn't replace anything.

I originally submitted this bugfix to Cocoon but found that of course the
Cocoon docs are now generated with Forrest. So I tracked down the equivalent
stylesheet in Forrest:


... and I found it had changed since the Cocoon version. So I'm not sending
the Diff I made for the Cocoon version: instead I'm just enclosing the extra
templates that could be added to this stylesheet. NB: I haven't used Forrest
at all, I don't have it installed, and I'm not in a hurry to do so, and in
fact I subscribed to the list just now, but I would like to fix this little
bug anyway - I hope that the format of this contribution will not be an


View raw message