Skip to content
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

HTML entities in wikilinks #105

Closed
kukimik opened this issue Jun 5, 2023 · 6 comments · Fixed by #109
Closed

HTML entities in wikilinks #105

kukimik opened this issue Jun 5, 2023 · 6 comments · Fixed by #109

Comments

@kukimik
Copy link
Contributor

kukimik commented Jun 5, 2023

The HTML entities are not recognized in wikilinks:

[["aaa"|bbb:ccc]]

results in

<p><a href="bbb&amp;colon;ccc" title="wikilink">&amp;quot;aaa&amp;quot;</a></p>

Compare this to ordinary links

[&quot;aaa&quot;](bbb&colon;ccc)
<p><a href="bbb:ccc">&quot;aaa&quot;</a></p>

Is this behaviour of wikilinks intentional or a bug? If it is intentional, what are the arguments that support it? It seems to be against the commonmark rules regarding entities.

If it is intentional, I believe some explanation should be included in the test files:

https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/wikilinks_title_after_pipe.md
https://github.com/jgm/commonmark-hs/blob/master/commonmark-extensions/test/wikilinks_title_before_pipe.md

If it is a bug, then I think changing untokenize to Commonmark.Entity.unEntity in Commonmark.Extensions.Wikilinks.wikilinksSpec should be enough to fix it? (And of course new test cases should also be included.)

@kukimik
Copy link
Contributor Author

kukimik commented Jun 28, 2023

@jgm I don't mean to stress you, but having seen your prompt replies in other issues, I thought you might have missed this one. I'll be happy to create a PR once it is clear what the expected behavior is.

@jgm
Copy link
Owner

jgm commented Jun 29, 2023

I haven't had time to look into this.
But have you tried this with GitHub wikilinks, obsidian wikilinks, etc.? Is there a standard behavior?
I remember looking into this before when designing the feature, and formatting inside wikilinks is often limited.

@kukimik
Copy link
Contributor Author

kukimik commented Jun 29, 2023

Thanks for your reply!

I've tried it and unfortunately there is no standard. GitHub and Notable recognize the entities both in the wikilink description and target, but on the other hand Obsidian behaves like commonmark-hs (and so does pandoc, which you probably already know).

In my opinion the entities should be recognized (because this behavior is consistent with the commonmark specification and I believe it usually is what the user intends), but I understand this may be controversial. I would be interested to hear the arguments supporting the current behavior.

Of course there is no rush. I fully understand you may be short on time.

@dixslyf
Copy link

dixslyf commented Jul 1, 2023

I tried it out on MediaWiki (which powers Wikipedia) and it also recognizes HTML entities in wikilinks (in both the title and the reference). You can try this out by opening the editor on any Wikipedia page.

I think it makes more sense to support entities in wikilinks. Given that ordinary links already recognize them, I find it surprising that wikilinks don't.

Users can still type out &nbsp; literally using &amp;nbsp; if needed, so supporting entities is more "general" in a sense.

@jgm
Copy link
Owner

jgm commented Jul 1, 2023

I think I'd be fine with this change. @kukimik Did you want to make a PR?

@kukimik
Copy link
Contributor Author

kukimik commented Jul 3, 2023

Yes, I'll do it, probably next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants