Skip to content

Clarify: emphasis delimiters inside link destinations are literal#378

Open
dereuromark wants to merge 2 commits into
jgm:mainfrom
dereuromark:fix/emphasis-in-link-destinations
Open

Clarify: emphasis delimiters inside link destinations are literal#378
dereuromark wants to merge 2 commits into
jgm:mainfrom
dereuromark:fix/emphasis-in-link-destinations

Conversation

@dereuromark

@dereuromark dereuromark commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Related: #375
JS implementation fix: jgm/djot.js#125
PHP implementation fix: php-collective/djot-php#81

Summary

Adds a clarifying note to the Precedence section of the syntax spec explaining that inline formatting delimiters inside link destinations are treated as literal text.

This covers the destination-only case:

  • _ or * inside a URL like (http://example.com?foo_bar=1) does not participate in emphasis matching

The bracket-text case (_[bar_](url)) is intentionally not changed - emphasis continues to take precedence per the existing "first to start wins" rule.

Per discussion in #375, this is the simpler fix that addresses the main real-world issue (URLs with underscores in query params) without the complexity of lookahead parsing.

@dereuromark dereuromark marked this pull request as ready for review February 8, 2026 16:54
@dereuromark dereuromark force-pushed the fix/emphasis-in-link-destinations branch from bdb9094 to 038b426 Compare February 8, 2026 17:13
Add a note to the Precedence section explaining that inline formatting
delimiters inside link destinations (URLs in parentheses) are treated
as literal text and don't participate in emphasis matching.

See jgm#375
@dereuromark dereuromark force-pushed the fix/emphasis-in-link-destinations branch from 038b426 to c854d7c Compare February 17, 2026 14:01
@dereuromark

Copy link
Copy Markdown
Contributor Author

@jgm This appears to still be open. I think with the merge of the others this should be good to go now.

@dereuromark

Copy link
Copy Markdown
Contributor Author

ping @jgm
@karlb whats your take on this? mergable as is?

@karlb

karlb commented May 20, 2026

Copy link
Copy Markdown

Looks good to me. It matches the test cases and the reference implementation and without this PR, I don't see a way to clearly argue why those should be correct.

@jgm

jgm commented May 20, 2026

Copy link
Copy Markdown
Owner

Note that inline formatting delimiters inside link destinations are
treated as literal text and do not interfere with emphasis matching.

This risks being tautological. Once you've decided that (url_) is a link destination, you've already decided that _ is not closing emphasis. Someone could accept the statement quoted above and still think that we have emphasis in _[test](url_), because they wouldn't be treating (url_) as a link destination. The example could still be helpful, but to my mind it departs from the general flavor of the document, which is not meant to be (and in far from being!) a complete specification. What I mean is this: if we include a discussion of this point, there are ever so many other similar sorts of things that would need to be specified exactly, not just in links but all over the syntax. (For example, do we need to say explicitly that a _ inside code backticks can't end emphasis? What is the difference, really, between that case and this one? They are both getting at issues of precedence that simply aren't clearly specified by this document. But this is just the tip of the iceberg...)

It would be desirable to have another document that precisely specifies the syntax, but I think we may be in danger of confusing the purpose of this document if we try to do this sort of thing here....

@karlb

karlb commented May 22, 2026

Copy link
Copy Markdown

It would be desirable to have another document that precisely specifies the syntax, but I think we may be in danger of confusing the purpose of this document if we try to do this sort of thing here....

Agreed, it's good to have one somewhat easily readable document the covers all normal syntax cases. Some ideas:

  • Further explanation and corner cases as separate doc, links from syntax.md
  • Add a collapsible (and by default collapsed) <details> section to the existing doc
  • Declare the test suite or certain parts of it to be part of the spec

Reframe the note as a precedence/ordering statement (constructs resolved
before emphasis matching) rather than a link-destination-specific rule.
This avoids the tautology concern and covers code spans too, keeping the
URL case as an illustration of the general rule.
@dereuromark

Copy link
Copy Markdown
Contributor Author

The implementations are already fixed and merged, so the substantive bug is resolved regardless; this is now purely about documentation, happy to adjust the wording to stay non-tautological.
Or we create such an additional page somewhere. Feel free to close if you think it doesn't help people to trip over the same issue.

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 this pull request may close these issues.

3 participants