How to mark wrapped lines?

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

How to mark wrapped lines?

Christian Franke
Hi,

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?

-Christian


Reply | Threaded
Open this post in threaded view
|

Re: How to mark wrapped lines?

G. Ken Holman
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.

I hope this helps.

. . . . . . . . . Ken


--
Public XSLT, XSL-FO, UBL & code list classes: Melbourne, AU May 2014 |
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/f/ |
G. Ken Holman                   mailto:[hidden email] |
Google+ profile:      http://plus.google.com/+GKenHolman-Crane/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com


Reply | Threaded
Open this post in threaded view
|

Re: How to mark wrapped lines?

Tony Graham-4
In reply to this post by Christian Franke
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
too hopeful.

FWIW, improved line numbering was in the XSL-FO 2.0 requirements [1] and
made an appearance in the XSL-FO 2.0 WD [2], but that has been shelved.

Regards,


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

[1] http://www.w3.org/TR/xslfo20-req/#additional-numbering
[2] http://www.w3.org/TR/xslfo20/#fo_number