Mojca Miklavec wrote:
Hello,
I was trying to figure out how to process simple HTML files with the new code, but I fail to understand the details. Here's a simple file I would like to process:
<html> <head> <title>My first HTML2ConTeXt</title> </head> <body> <h1>Main Title</h1> <p>Some text ...</p> <h2>Subtitle</h2> <p>Some text again ...</p> <h1>Second title</h1> <p>... and not much more text here either ...</p> </body> </html>
And the failed tries here:
% engine=luatex \setupcolors[state=start] \setuphead[subject][style=bfa,color=blue] \setuphead[subsubject][style=tfa,color=blue]
\starttext \xmlload{main}{test.html}{} \xmlgrab{main}{h1}{h1} \xmlgrab{main}{h2}{h2}
\startxmlsetups h1 \subject{H1: #1} \stopxmlsetups
\startxmlsetups h2 \subsubject{H2: #1} \stopxmlsetups
How to grab only the title out of here?
\xmlfilter{main}{html/head/title}
\xmlflush{main} \stoptext
Any hints most wellcome.
keep in mind that this is still somewhat experimental % best define mappings before loading the file \startxmlsetups all:html \xmlsetsetup{main}{head|h1|h2}{*} \stopxmlsetups \xmlregistersetup{all:html} % register this so that it's done for each load \startxmlsetups h1 \subject{\xmlflush{#1}} \stopxmlsetups \startxmlsetups h2 \subsubject{\xmlflush{#1}} \stopxmlsetups \startxmlsetups head \startstandardmakeup THIS IS ABOUT: \xmlfilter{main}{/head/title/text()} \stopstandardmakeup \stopxmlsetups % that's it \setupcolors[state=start] \setuphead[subject][style=\bfd,color=blue] \setuphead[subsubject][style=\bfc,color=blue] \starttext \xmlprocess{main}{test.html}{} \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------