At 2014-03-08 23:21 +0100, Christian Franke wrote:
>I would like to typeset some source code and automatically wrap lines.
>This should be possible without a loss of information iff there is some
>kind of marking which allows the reader to recognize wrapped lines.
>Is that somehow possible with xsl-fo?
How I do this in my training material is that I preface each line
with a line number in a small font, so that the line begins indented
from the left, and then I let the wrapping go all the way to the left
and so can be seen between two starts of lines.
If every line is numbered, then you could simply wrap at the same
indent level and the user knows that the line is wrapped due to the
absence of a line number.
If you don't want to use line numbers, then you could use a graphic
at the start of every line and the absence of the graphic is an
indication of a wrapped line.
I cannot think of a way of introducing a visual marker of a wrapped
line, I can (and could at the time) only think of using the absence
of a visual marker to indicate a wrapped line.
On Sat, March 8, 2014 10:21 pm, Christian Franke wrote:
> I would like to typeset some source code and automatically wrap lines.
> This should be possible without a loss of information iff there is some
> kind of marking which allows the reader to recognize wrapped lines.
> Is that somehow possible with xsl-fo?
Not out of the box.
If you know the line width, you could break the lines yourself using XSLT
and insert a marking character, but then the line breaks and marking
characters would be included if someone copied the source code from PDF
output or similar.
You could put every line in a separate fo:block and alternate
background-color of alternate fo:block.
If your FO formatter supports change-bars, you could use one
fo:change-bar-begin/fo:change-bar-end for the entire source code listing
and at the start of every line add another
fo:change-bar-start/fo:change-bar-end for a different change-bar-class
with a higher z-index and a width and style such that the change-bars for
the start of the lines overlay the other change-bar with the background
color so that you only see the other change-bar alongside the continuation
lines (and hopefully don't see a succession of hairline change-bars where
the per-line change-bars don't quite overlap).
Keeping with the change-bar idea, you could alternate change-bars of
different colours on alternate lines.
If you use the line-numbering extension in Antenna House, it will number
the formatted lines, not the source lines, so a wrapped line will show as
multiple line numbers.
If you are using Antenna House, you might be able to try setting
"hyphenation-charater" and "axf:soft-hyphen-treatment", but I wouldn't be
FWIW, improved line numbering was in the XSL-FO 2.0 requirements  and
made an appearance in the XSL-FO 2.0 WD , but that has been shelved.
Tony Graham [hidden email] Consultant http://www.mentea.net Chair, Print and Page Layout Community Group @ W3C XML Guild member
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Mentea XML, XSL-FO and XSLT consulting, training and programming