ocsigen / tyxml

Build valid HTML and SVG documents
https://ocsigen.org/tyxml/
Other
166 stars 58 forks source link

Templating and ppx for tyxml #68

Open Drup opened 9 years ago

Drup commented 9 years ago

There has been several request of a templating method in tyxml. Also, with the various other ppx coming, finally cleaning up the syntax extension question might be a good idea.

Here are my notes and ideas on how to do it:

  1. Having a decent html parsing library. Either we use something simple that only parses valid html, or something more complicated (see this discussion in particular). It doesn't have to be the first thing done.
  2. Create a systematic way to translate html documents into tyxml function. Currently, some functions in tyxml are not exactly the html element's name (because of syntactic restriction in html, or disambiguation, and so on). This would also be the occasion to normalize and rationalize tyxml's naming convention. @Eyyub started such work in https://github.com/Eyyub/ppx_tyxml
  3. Write a ppx for a syntax extension and something that can take an html tree with holes and produce an ocaml function out of it. It will basically be the exact same thing anyway.
Drup commented 8 years ago

A lightweight resilient html5 parser is now available: https://github.com/aantron/markup.ml/

Drup commented 8 years ago

On point 2., also see https://github.com/ocsigen/tyxml/issues/72

aantron commented 8 years ago

Can you give some more detail on what you would want for the second (non-syntax) part of point 3?

Drup commented 8 years ago

Well, basically, create an executable that takes a file containing bits of html or svg (like some templating thingy) and output an ocaml file. We could reuse some classic template syntax such as mustache.

Drup commented 8 years ago

WIP version in https://github.com/ocsigen/tyxml/pull/128