SRFI AsciiDoc->HTML converter Lassi Kortela (09 Sep 2019 10:56 UTC)
Re: SRFI AsciiDoc->HTML converter Duy Nguyen (09 Sep 2019 11:05 UTC)
Re: SRFI AsciiDoc->HTML converter Lassi Kortela (09 Sep 2019 11:17 UTC)
Re: SRFI AsciiDoc->HTML converter Duy Nguyen (09 Sep 2019 11:25 UTC)
Re: SRFI AsciiDoc->HTML converter Lassi Kortela (09 Sep 2019 11:41 UTC)
Re: SRFI AsciiDoc->HTML converter John Cowan (09 Sep 2019 13:05 UTC)
SXML in general Lassi Kortela (09 Sep 2019 13:18 UTC)
Re: SXML in general John Cowan (09 Sep 2019 13:20 UTC)
Re: SXML in general Lassi Kortela (09 Sep 2019 13:31 UTC)
Re: SXML in general John Cowan (09 Sep 2019 14:06 UTC)

Re: SRFI AsciiDoc->HTML converter Duy Nguyen 09 Sep 2019 11:25 UTC

On Mon, Sep 9, 2019 at 6:17 PM Lassi Kortela <xxxxxx@lassi.io> wrote:
>
> > Off topic. But if anyone wants to write in markdown instead,
> > commonmark can export to xml. You can do some extra processing in sxml
> > before transforming to html, which is not that complicated with
> > pre-post-order [1]
> >
> > [1] https://gitlab.com/pclouds/cuibap/blob/master/cuibap/commonmark.scm#L50
>
> Cool! It'd be great if the tool could be extended to handle Markdown in
> addition to AsciiDoc. I prefer AsciiDoc because it has more solid
> support for advanced features like tables, but Markdown is more popular.
>
> The tool:
>
> 1. Runs `asciidoctor` to turn AsciiDoc into HTML.
> 2. Uses (chibi html-parser) to turn the HTML into SXML.
> 3. Does tree transforms to remove asciidoctor boilerplate from the SXML.
> 4. Uses (chibi sxml) to turn that SXML back into HTML.
> 5. Runs `tidy` to normalize the HTML and writes it into a .html file.
>
> So the parts before the tree transforms could be done using commonmark
> if the source filename ends in ".md" instead of ".adoc".

Yeah. commonmark does not produce "html in xml tags" though. So step 4
may need some more work. The good thing is html export from sxml (at
least Gauche version) is pretty clean.

If I remember correctly the sxml library produces broken html5 tags
sometimes [1], maybe that's why you need 'tidy'?

[1] https://github.com/shirok/Gauche/pull/322

> What is the tree transform library you are using in cuibap? I
> hand-rolled my own transformation primitives for this program. It'd be
> great to have a portable transformer lib in Snow.

pre-post-order function is part of sxml (or maybe sxpath?) library.
For Gauche it's in sxml.tree-trans library. I think I've seen it in a
couple other Scheme implementations too.
https://wingolog.org/pub/fold-and-xml-transformation.pdf could be a
good read about it (and another thing).
--
Duy