Skip to content

Treat explicit markup lines as non-titles in RST parser#1335

Open
lacatoire wants to merge 2 commits intophpDocumentor:mainfrom
lacatoire:feature/forgiving-anchor-parsing
Open

Treat explicit markup lines as non-titles in RST parser#1335
lacatoire wants to merge 2 commits intophpDocumentor:mainfrom
lacatoire:feature/forgiving-anchor-parsing

Conversation

@lacatoire
Copy link
Copy Markdown
Contributor

Closes #1240.

When an anchor (or any explicit markup line like a comment or directive) sits directly above a section underline without an intervening blank line, the parser used to greedily treat the markup line as the section title text. With this change, TitleRule::applies() skips lines that start with .. followed by whitespace (or a lonely ..), so the body rules (e.g. LinkRule) can claim them and the next paragraph becomes the actual title, exactly as docutils does.

Validated by a new integration fixture anchor-no-blank-line/ covering both single-space and double-space anchors directly above section titles.

When a line starting with '..' (anchor, comment, directive) is followed
directly by a section underline without a blank line, the parser used
to treat the whole markup line as the title text. It now skips title
detection on explicit markup lines so the appropriate body rule
(LinkRule, CommentRule, ...) can claim them, and the next paragraph
becomes the section title.

Closes phpDocumentor#1240
Hosts the helper next to its siblings (isLink, isDirective, isAnnotation),
aligns its regex flags with the rest of the file, and exercises
sub-section underlines, phrase-reference anchors and stacked anchors.
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.

Be more forgiving in specifying anchors

1 participant