Mailing List Archive

HTML bettering?
How to make as simple as tool which would make some simple operation
over HTML (e.g., headings numbering)? If I would use htmllib.py, I would
have to build HTMLformatter or I am wrong and it is easy?

Thanks

Matthew
HTML bettering? [ In reply to ]
* Matej Cepl
|
| How to make as simple as tool which would make some simple operation
| over HTML (e.g., headings numbering)? If I would use htmllib.py, I
| would have to build HTMLformatter or I am wrong and it is easy?

You could very well use htmllib and just make an htmllib application
that writes the HTML back out again, and modify it slightly to do
heading numbering. I don't think HTMLFormatter would do you any good
for this sort of thing.

However, HTML isn't a very good SGML application for this sort of
thing, since the following is entirely legal:

<!DOCTYPE ...>
<HTML>
...

<BODY>
<H5>On the topic of nesting</H5>

<H2>Why it's good</H2>

<H4>And why HTML doesn't have it</H4>

...
</HTML>


ISO HTML provides a better starting point for this sort of thing, as
do most other SGML applications intended for articles.

Personally, I use a private SGML DTD for my articles and then use
DSSSL stylesheets to produce the HTML, complete with a table of
contents. Adding heading numbering should take all of 5 minutes. :)

And today I've put together the infrastructure to produce PDF from the
same SGML source as well.

Here's an example:

<URL: http://www.stud.ifi.uio.no/~larsga/download/artikler/perl.html>

--Lars M.
HTML bettering? [ In reply to ]
Lars Marius Garshol writes:
> You could very well use htmllib and just make an htmllib application
> that writes the HTML back out again, and modify it slightly to do
> heading numbering. I don't think HTMLFormatter would do you any good
> for this sort of thing.

Or you could add a skip=0 or seqnum=1 attribute to the first H?
element, and then use Grail to display it all... ;-) (If Grail
detects header sequence information, it turns on auto-numbering.
Kinda neat! ;)


-Fred

--
Fred L. Drake, Jr. <fdrake@acm.org>
Corporation for National Research Initiatives
HTML bettering? [ In reply to ]
Matej Cepl <Cepl@fpm.cz> wrote:
>How to make as simple as tool which would make some simple operation
>over HTML (e.g., headings numbering)? If I would use htmllib.py, I would
>have to build HTMLformatter or I am wrong and it is easy?
>
Does it have to be a selfmade Python solution? If you just want to
number your headlines (and if you speak Perl), have a look at WML[1]
which combines embedded Perl, m4, MetaHTML, an HTML optimizer and five
other passes your input script is fed into. It's under GPL and fairly
well documented.

HTH
Konrad

____
1: http://www.engelschall.com/sw/wml/



--
n_n_n_n_n LOOK, DOGBERT, I'VE INVENTED A MACHINE THAT POSTS USELESS
| | / MESSAGES INTO NEWSGROUPS AND STARTS FLAMEWARS.
|---()()| /
| ( )| / <kanton@gmx.de> (Konrad Anton)
HTML bettering? [ In reply to ]
> From: KAnton@gmx.de (Konrad Anton)
> Date: Thu, 17 Jun 1999 18:53:36 +0159
>
> Does it have to be a selfmade Python solution? If you just want to
> number your headlines (and if you speak Perl), have a look at WML[1]
> which combines embedded Perl, m4, MetaHTML, an HTML optimizer and five
> other passes your input script is fed into. It's under GPL and fairly
> well documented.
>
[MCepl] Well, it is not the biggest support of Python's
goodwill, is it? But, to make Pythonians more happy, the story is as
follows: I am writing some stuff in Amaya, which has beautiful heading
numberings, but its priting abilities are rather questionable (it fails
three times from four attempts -- on WinNT) so I would rather use
html2ps which has much better output, but it numbers headings in
different way (still unresolved issue, what it the top level -- H2 or
H1?). So I needed some simple tool to make numbering in the text (BTW,
it would be usefull for latter presentation in, say, widely spread
browsers).

I sent a notice to amaya list and I have got small script in
Perl in about quarter of hour. It works, it is beautiful, but it is
totally incomprehensible for me, how it works (my knowledge of Perl is
fairly limited -- what is push and pop?). Therefore, I ask again, if
there is some simple way, how to show power of Python's libraries system
(htmllib.py, I guess).

Have a nice day and sorry for
slightly off-topic


Matthew
HTML bettering? [ In reply to ]
Matej Cepl writes:
> goodwill, is it? But, to make Pythonians more happy, the story is as

A worthy goal! ;-)

> html2ps which has much better output, but it numbers headings in
> different way (still unresolved issue, what it the top level -- H2 or

There are a couple of these out there, including one in Python
included with the Grail sources. Someone posted a patch to it on the
Grail list, so I'm not sure of the current state of it, but I could
probably answer a few quick questions about it.


-Fred

--
Fred L. Drake, Jr. <fdrake@acm.org>
Corporation for National Research Initiatives
HTML bettering? [ In reply to ]
<14186.24371.249981.43774-@weyr.cnri.reston.va.us> wrote:
Original Article: http://www.egroups.com/group/python-list/?start=61289
>
> Matej Cepl writes:
> > goodwill, is it? But, to make Pythonians more happy, the story is as
>
> A worthy goal! ;-)
>
> > html2ps which has much better output, but it numbers headings in
> > different way (still unresolved issue, what it the top level -- H2 or

Or if your HTML is well structured you can use the html2pdf converter in the Zpdf (it is an alpha release) package
http://starship.python.net/crew/pavlos

It does heading numbering too.

Pavlos