[cl-typesetting-devel] HTML rendering

Klaus Weidner klaus at atsec.com
Sun Apr 18 17:05:52 UTC 2004


On Sun, Apr 18, 2004 at 02:46:04PM +0200, Marc Battyani wrote:
> "Klaus Weidner" <klaus at atsec.com> wrote:
> > I've extended cl-typesetting a bit, to support cross-referencing (needed
> > for the table of contents and intra-document page references), left/right
> > page header alternation (containing chapter titles) and some other minor
> > stuff.
> 
> Good. I will add this to cl-typesetting.

I'm still planning to clean this up and add some docstrings, but I guess
updating this later should not be a problem.

BTW, I'm currently handling the forward references by completely
re-running the layout engine if unresolved dependencies were detected,
similar to the way LaTeX does it. Any remaining unresolved ones get
reported (well, printed to stdout) after the second pass. There may be
more direct ways to handle this, but the current approach works
well enough and has the advantage of being very simple.

There may be rare cases where replacing the "999" currently used in the
first pass for forward references would cause a change in pagination (and
therefore wrong references) when replaced by a different number of digits
on the second run. Currently the code just ignores this, but it would be
possible to add checks to see if the marks moved.

> > I've attached the :fresh-page patch, and sample code to demonstrate the
> > new features. The latter is still a bit messy and undocumented, it's a
> > work in progress.
> 
> It will probably match the cl-typesetting doc anyway.

;-)

> > The XHTML transformer is still too unfinished for distribution, but please
> > let me know if you're interested in that and I'll work on cleaning it up.
> > But I'm surprised at how well it works already, considering that most of
> > my time had been spent figuring out how things work.
> 
> Of course I'm interested! Please send it as soon as you feel it's clean
> enough.

That depends on when I can find time to do more hacking on it - I'd like
to have it support the "everything.html" file completely. But if it turns
out that I can't find the time, I'll post what I have and let others
worry about it.

> >   Also, I'm not sure what a "trie" is (used by hyphenation). And I think
> >   that keyword arguments should not use a "-p" suffix.
> 
> A trie is a kind of search tree (prefix).

Thanks, I guess I should have asked Google right away...

> What keyword arg are you talking about ?

I've found the following initargs and function keyword args:

	:adjustable-p
	:splitable-p
	:trimable-p

In the CL libraries, the -p suffix is used just for predicate functions
and not for boolean keyword arguments. I think that (... :adjustable t)
is more readable.

> > - I don't know how leaders (the dots joining table-of-content entries to
> >   the page numbers) should be implemented. Note that the dots should line
> >   up even if the TOC entries have different lengths, so it's not a simple
> >   matter of sticking periods in boxes.
> 
> IMO it's only a matter of sticking the correct number of dots with a hfill
> between the last word and the dots. The only trouble is to compute the
> correct number of dots ;-)

I don't think it's that simple - once you have a box containing the right
number of dots, you still need to position it exactly by inserting glue
in the front to handle the width variations of the preceding text - it
looks extremely ugly if they don't line up vertically on different lines.

Also, this may just be a lack of understanding on my part, but what would
the best way be to handle the case where the title is too long to fit in
a single line? Something like this:

   Chapter one . . . . . . . 3

   Chapter two with a really
   long title  . . . . . . . 5

Note that the first line should not run into the numbers column, and the
last line needs to have the dot fill. Hmmm, seems to be a candidate for a
paragraph that has a different right margin for the last line, kind of a
reflection of the way the first-line-indent works.

Also, there should be a way to completely control the additional glue
added during line breaking - I think at the moment there's no way to
prevent the last line from getting an additional hfill added which would
break the layout.

> > - PDF hyperlinks aren't handled yet by the typesetting code - how about a
> >   link-box class which acts as a clickable area for the bounding box of
> >   the content?
> 
> I wanted to do this but it's not so simple. I have a few ideas on how to do
> it. I will try to find some time to implement them.

A problematic area is matching up the references the typesetting layer
knows about with the PDF cross-references. Note that my referencing code
currently saves the page number and the x/y position for the mark, does
that help?

> BTW what about the CMUCL problems ?

The only way I can get the code loaded on CMUCL is by moving the
def-function into a separate file (i.e. zlib.lisp), which is loaded after
the load-foreign-library was run. No changes within init.lisp worked,
since it doesn't even load if there's an unresolved reference to
"compress".

-Klaus




More information about the cl-typesetting-devel mailing list