See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dfn
It would be good to parse
<dfn id="def-validator">validator</dfn>
as (pandoc markdown)
[validator]{#def-validator .definition}
and if we did that we could also render this construction to HTML using a <dfn> element.
I'd like to implement this. Am I right to assume that this is best done by adding a new Inlines in pandoc-types (Definition and a definitionWith builder) and then adding the readers/writers in pandoc proper? @jgm
<dfn> can have other elements as children which I'd just let pandoc handle. I'm just not sure if something like [[link](www.example.com)]{#def-validator .definition} would work, although I'd assume it would. Considering that many Inlines can have other Inlines as children.
I'd like to implement this.
Great!
Am I right to assume that this is best done by adding a new Inlines in pandoc-types
No, we would like to avoid changing pandoc-types, as this has the potential to break a lot of existing pandoc filters.
The idea is to parse
<dfn id="myid" title="mytitle">validator</dfn>
to (try with pandoc -f html -t native):
Span ("myid",["definition"],[("title", "mytitle")]) [Str "validator"]
Have a look at https://github.com/jgm/pandoc/pull/5843/ for a similar pull, and maybe https://github.com/jgm/pandoc/blob/master/CONTRIBUTING.md#tests
So upon implementing this a couple more questions came up. If I turn this into a Span, I'd have to add special handling for that to the (Span (id',classes,kvs) ils) -> case of the HTML Reader. Because currently it would just output a <span> but we want a native <dfn> when using -t html. More specifically, that could would logically affect the case when we don't have an htmlSpanLikeElement
Nothing -> do
h <- inlineListToHtml opts ils
addAttrs opts (id',classes',kvs') (H.span h)
As far as I see it there are two options:
SpanhtmlSpanLike so attributes are added to the resulting DOM node (currently <dfn id="foo">test</dfn> is turned into <dfn>test</dfn> when doing html -> html)I think the second option sounds reasonable. Anyone else have thoughts on this?
Just in case someone's wondering I finally found some time to work on this and will have a PR up for discussion tomorrow
Most helpful comment
I think the second option sounds reasonable. Anyone else have thoughts on this?