fix: allow newlines inside bracket link path#94
Open
LoganBarnett wants to merge 1 commit into
Open
Conversation
Emacs org-mode treats bracket links as inline objects bounded by their enclosing element (paragraph, list item, etc.), not by a single line. A `[[path]]` or `[[path][desc]]` may span a newline inside either part and is still recognised as one link. orgize 0.10 previously excluded `\n` from the path `take_while`, so multi-line links written by Emacs were dropped on parse. Description parsing already allowed newlines. The element-level parsers (e.g. `paragraph_node`) already bound the input passed to `link_node` at blank lines, so removing the per-link newline restriction cannot let a link escape its element.
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.
Summary
Emacs org-mode treats bracket links as inline objects bounded by their
enclosing element (paragraph, list item, etc.), not by a single line. A
[[path]]or[[path][desc]]may span a newline inside either part and isstill recognised as one link by Emacs.
orgize previously excluded
\nfrom the pathtake_while, so multi-linelinks written by Emacs were silently dropped on parse. Description parsing
already permitted newlines, so this PR is a single-character change in
src/syntax/link.rsplus regression tests.Why this is safe
Element-level parsers (
paragraph_node, list item bodies, etc.) alreadybound the input passed to
link_node— paragraphs terminate at blanklines, so the input slice handed to the link parser cannot extend past
the surrounding element. Removing the per-link newline restriction
therefore cannot let a link swallow material beyond its element.
Reproducer
The downstream project org-fmt
hit this when round-tripping documents written in Emacs:
Tests
Three new tests in
src/syntax/link.rs:parse_multiline_link—link_nodedirectly, covering bothnewline-in-path and newline-in-description cases (snapshot assertions).
parse_multiline_link_in_paragraph— end-to-end viaOrg::parse,matching the downstream reproducer.
Full suite passes (148 tests), no regressions.
Notes
The commit message references the related precedent (
5bc15d8 fix: newline in not allowed in property name) where the project intentionally tightenednewline handling. This change goes the other direction for links, where
Emacs explicitly allows newlines.