ocsigen/tyxml

tables with ppx

Ngoguey42 opened this issue · 3 comments

I'm having a hard time creating tables using the ppx syntax.

This works:

[%html "<tablex>"[tbody []]"</tablex>"]

Those fail with a type error:

[%html "<tablex>"[thead []; tbody []]"</tablex>"]
[%html "<tablex>"[thead []]"</tablex>"]

And those two fail with Error: Bad content in 'table':

[%html "<table>"[tr []]"</table>"]
[%html "<table>"[thead []]"</table>"]
Drup commented

Hmm, this is a tricky error.

  1. tablex shouldn't exist in the syntax. table is the right name of the element, tablex is just a way to encode incompatible way of using table in the OCaml type system. We should not expose that distinction in the PPX syntax.
  2. markup tells us that this particular use of table is not correct, because it's missing stuff inside ... but the typesystem will check that anyway, and better.

It's not the only case where 2. triggers, and it's fairly problematic. Ideally, I would like markup to avoid caring about these particular checks, there are multiple ways of doing that.

Drup commented

I pushed something that might help a bit, but it's clearly not perfect.

  1. You can't use thead for an antiquotation like this. You must inline it (or use the combinator)
  2. If you use tr in antiquotations, you should wrap it in a tbody.

I don't have any ideas to do much better than that, so I'm going to close, but feel free to ask more questions!

Thanks!