feat(pampa): better diagnostic for line breaks in inline link destinations#207
Merged
Merged
Conversation
…tinations
When an inline link destination contains a hard line break
(e.g. `[text](https://\nhost/path)`), pampa rejected the input with a
generic "unexpected character or token here" message. CommonMark forbids
line breaks in inline link destinations, so the rejection is correct,
but the message was unhelpful.
This adds a Q-2-37 corpus entry covering the (LR state, lookahead) pairs
the parser hits when a newline appears inside a link destination
(state 2619 with both `shortcode_name` and `_close_block` lookaheads).
Pampa now emits a specific message naming the cause and a single hint.
Output:
Error: [Q-2-37] Line break in link destination
╭─[ file.qmd:2:1 ]
│
2 │ allisonhorst.github.io/palmerpenguins/) dataset.
│ ──────┬─────
│ ╰─────── An inline link destination cannot contain a line break.
───╯
ℹ Remove the line break inside the link's `(...)` destination and keep the URL on a single line.
A new regression test (`tests/test_link_destination_linebreak.rs`) covers
the bug-report fixture plus three minimal variants (newline after the
scheme, mid-destination, before the closing `)`). The existing
`test_error_corpus_*` tests automatically exercise the three generated
case files.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Also TIL about the Jeffery TOPLAS-2003 technique - super cool |
Member
Yes, it truly is! I only know about it because of a PL prof friend of mine. We're currently running into the limits of the technique for error messages here because parsing Markdown is, well, hell. But it's super cool, super simple, and wild that we could make it work inside tree-sitter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an inline link destination contains a hard line break (e.g.
[text](https://\nhost/path)), pampa rejected the input with a generic "unexpected character or token here" message. CommonMark forbids line breaks in inline link destinations, so the rejection is correct, but the message is unhelpful.This adds a Q-2-37 corpus entry covering the (LR state, lookahead) pairs the parser hits when a newline appears inside a link destination (state 2619 with both
shortcode_nameand_close_blocklookaheads). Pampa now emits a specific message naming the cause and a single hint.Output:
A new regression test (
tests/test_link_destination_linebreak.rs) covers the bug-report fixture plus three minimal variants (newline after the scheme, mid-destination, before the closing)). The existingtest_error_corpus_*tests automatically exercise the three generated case files.The error location seems not ideal but I was not able to fix that without subjecting the codebase to much more significant changes than seemed warranted so I will leave that up to you to address.