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

Warn about incomplete symbol links ( Link ` ) #165

Open
d-ronnqvist opened this issue Feb 14, 2024 · 3 comments
Open

Warn about incomplete symbol links ( Link ` ) #165

d-ronnqvist opened this issue Feb 14, 2024 · 3 comments

Comments

@d-ronnqvist
Copy link
Contributor

It's easy to make a typo when writing symbol links and close the link with only a single backtick (`). For example,

Some text with a ``Link` followed by some more text.

The example markup above parses as a single text element, making it hard for other tools that use Swift Markdown to diagnose the issue.

Paragraph
└─ Text "Some text with a ``Link` followed by some more text."

For comparison, if the same markup was written like ``Link`` or Link then it parses as 3 distinct elements.

Paragraph
├─ Text "Some text with a "
├─ SymbolLink destination: Link
└─ Text " followed by some more text."

or

Paragraph
├─ Text "Some text with a "
├─ InlineCode `Link`
└─ Text " followed by some more text."
@d-ronnqvist d-ronnqvist changed the title Warn about incomplete symbol links (`Link) Warn about incomplete symbol links (<code>`Link</code>) Feb 14, 2024
@d-ronnqvist d-ronnqvist changed the title Warn about incomplete symbol links (<code>`Link</code>) Warn about incomplete symbol links (\\Link\`) Feb 14, 2024
@QuietMisdreavus QuietMisdreavus changed the title Warn about incomplete symbol links (\\Link\`) Warn about incomplete symbol links (``Link\) Feb 14, 2024
@QuietMisdreavus QuietMisdreavus changed the title Warn about incomplete symbol links (``Link\) Warn about incomplete symbol links (` Link ``) Feb 14, 2024
@QuietMisdreavus QuietMisdreavus changed the title Warn about incomplete symbol links (` Link ``) Warn about incomplete symbol links ( Link `) Feb 14, 2024
@QuietMisdreavus QuietMisdreavus changed the title Warn about incomplete symbol links ( Link `) Warn about incomplete symbol links ( Link ` ) Feb 14, 2024
@QuietMisdreavus
Copy link
Contributor

It looks like this is down to behavior in swift-cmark; the upstream CommonMark/GitHub-Flavored Markdown spec says that mismatched delimiters are emitted literally:

When a backtick string is not closed by a matching backtick string, we just have literal backticks:

```foo``
<p>```foo``</p>

It might be possible to add an optional flag to swift-cmark that enables some more permissive parsing behavior, but this would break compatibility with CommonMark and GitHub-Flavored Markdown.

@d-ronnqvist
Copy link
Contributor Author

Does Markdown have a mechanism for emitting warnings? If so, it could continue to emit the parsed content according to the spec but also give callers an indication of potential syntax issues.

@QuietMisdreavus
Copy link
Contributor

QuietMisdreavus commented Feb 14, 2024

It does not; the parsing philosophy in Markdown is to be maximally permissive and always fall back to emitting the text as given. GFM (like CommonMark before it) does not emit any warnings about content whatsoever.

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

No branches or pull requests

2 participants