Remove static phrasing content by wooorm · Pull Request #42 · syntax-tree/mdast (original) (raw)
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
- If applicable, I’ve added docs and tests
Description of changes
Previously, there was a difference between static and dynamic phrasing
content.
There was also transparent content, to “inherit” the (static or dynamic)
content model from a parent.
This was used to prohibit links in links.
However, while it is unwise to put links in links, it is possible with
markdown to do so, by embedding autolinks in links with resources or
references.
Take for example:
alpha https://bravo charlie
Yields, per CommonMark:
alpha https://bravo charlie
See also: commonmark/commonmark-spec#719.
There is also the case where while it is unwise to author such markdown,
tools transforming mdast might inject links.
It’s probably good to handle such cases in mdast-util-to-markdown
and
such?
Not allowing links in links is also something imposed by HTML (particularly
the parsing side1): perhaps mdast could be used in places where this
restriction doesn’t need to be imposed.
Finally, it is hard to type such inherited content models.
As in, transparent content is not used in @types/mdast
(I don’t think it
can be typed?):
So, this PR is a proposal to remove the difference and simplify the AST.
Footnotes
- You can produce nested
a
s with the DOM:
let a1 = document.createElement('a'); a1.textContent = 'alpha';
let a2 = document.createElement('a'); a2.textContent = 'bravo';
a1.appendChild(a2)
document.body.appendChild(a1)