NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: breaking down the browser (was Re: Web browser: stuck with Opera-9.62)

On Thu, Feb 23, 2012 at 08:51:18PM +0100, wrote:
> On Thu, Feb 23, 2012 at 11:23:55AM -0600, David Young wrote:
> > 
> > You could produce a browser for UNIX by composing simple programs, but
> > you'd have to set out from the beginning with a lot of discipline.
> > [...] 
> > 
> > repeat(repeat(fetch | layout) | render ; read user input)
> And perhaps someday someone will remember that we have at least already
> a layout engine able to render text and maths: TeX. That we have the
> fonts. Etc.
> For someone wanting to "play" with the idea, one could start by
> translating simple HTML into TeX macros (designed for the purpose), and
> displaying the TeX formatted result... page by page, with the
> ability to have finally something printable.

The Knuth-Plass algorithm and the idea of boxes, glue, and penalties are
both really powerful.  It is too bad that they are almost completely
overlooked/forgotten in the world of web development[1]!

Another way to accomplish what you propose is a filter that
replaces/augments HTML markup with markup about boxes, penalties, and
glue. Call the markup bpg; call the filter html-to-bpg. html-to-bpg
transforms the HTML

        <div class="para">Another way to accomplish what you propose is a 
filter that
        replaces/augments HTML markup with markup about boxes and glue:</div>

to XML with boxes, penalties, and glue marked with <b>, <p>, and <g>,
the width at which to set the paragraph given by <bounds>, and the
original markup moved to the 'html' namespace:

        <bounds width="500"><html:div class="para"><b>An<p 
cost="50">-</p>other</b><g> </g><b>way</b><g> </g><b>to</b><g> </g><b>ac<p 
cost="50">-</p>com<p cost="50">-</p>plish</b><g> </g><b>what</b><g> 
</g><b>you</b><g> </g><b>pro<p cost="50">-</p>pose</b><g> </g><b>is</b><g> 
</g><b>a</b><g> </g><b>fil<p cost="50">-</p>ter</b><g> </g><b>that</b>
<g>     </g><b>re<p cost="50">-</p>places/<p cost="50"/>aug<p 
cost="50">-</p>ments</b><g> </g><b>HTML</b><g> </g><b>markup</b><g> 
</g><b>with</b><g> </g><b>markup</b><g> </g><b>about</b><g> </g><b>boxes</b><g> 
</g><b>and</b><g> </g><b>glue:</b><p cost="inf"/><g stretchability="inf" 
shrinkability="0"/><p cost="-inf"/></html:div></bounds>

Let another filter break the paragraph into lines and assign x,y
coordinates (or row,column coordinates for character-cell displays) to
the boxes and penalties that should be drawn.  Call this filter 

The Knuth-Plass paper, "Breaking Paragraphs Into Lines", shows
how to format an ALGOL-like language in a pleasing way using
boxes & glue.  Suppose I had a parametrized c-to-bpg filter.
Then I can re-use bpg-format with c-to-bpg in a pipeline,
c-to-bpg <parameters> < program.c | bpg-format, that pretty-prints
C the way I like best.

Finally, what if somehow by interacting with the *output* of that
pipeline I could modify its *input*, so that Richard Stallman and I
could modify the same C program, Richard with a GNU-style view of it,
and I with a BSD-style view of it.  This is something that I have been
thinking about a lot.


[1] These days there is a lot of buzz about something called "responsive
web design," the idea being that your website should adapt its
appearance to the width and other properties of the display device,
be that an iPhone, tablet, or 50-inch high-def TV.  That nobody (to
my knowledge) is talking about Knuth-Plass in that context seems very

David Young    Urbana, IL    (217) 721-9981

Home | Main Index | Thread Index | Old Index