-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent children contents for link vs wikilink node value #536
Comments
@digitalmoksha Thoughts on such a change? This is a bit of a philosophical matter, since CommonMark specifies that a link without a title should be empty, and therefore it must have no contents. The closest thing we have to a spec for wikilinks, on the other hand, specifies that a wikilink without an explicit title should contain the link as its title. Whether that happens at the rendering stage or the parsing stage is indeed up to us; I sympathise with wanting to preserve the information. |
@mfontanini The thing with wikilinks is that if there is not title specified, then the link and the title are the same thing. So when that link gets rendered, we expect the text of the HTML link to be that link, which is usually just a page name like "How to contribute" or something. So And CommonMark, as @kivikakk mentioned, specifies that if there is no title, then no text is in the link. So therefore no child text node. As you can see in https://spec.commonmark.org/dingus/?text=%5B%5D(http%3A%2F%2Fexample.com)%0A I suppose you could argue that we could put an empty text node in markdown links without a title, but I'm not really sure that would buy us anything. |
I think @mfontanini is suggesting we could parse the wikilink with an empty title (so you can tell, in the AST, whether or not there was in fact a title specified with a There's another question about what to do if a title is specified but empty ( |
Ah ok, I guess that makes sense. |
@mfontanini I think we're all good for this change! Please do open a PR, and feel free to give us a ping if you get stuck. :) |
The link and wikilink node values have inconsistent children node shapes when a title is present. For normal links, when there is no title, the node has no children. For wikilinks, when there is no title, the node has one children that contains the link itself. This makes it hard for parsers to distinguish between a wikilink with title and one without.
To reproduce run this code:
Notice the output below. I would have expected that link1 and link3 should have the same shape (no children), but they don't.
I can probably create a PR to fix this myself, but this will be a breaking change so I would like someone to give it the green light before I do so.
The text was updated successfully, but these errors were encountered: