Treat explicit markup lines as non-titles in RST parser#1335
Open
lacatoire wants to merge 2 commits intophpDocumentor:mainfrom
Open
Treat explicit markup lines as non-titles in RST parser#1335lacatoire wants to merge 2 commits intophpDocumentor:mainfrom
lacatoire wants to merge 2 commits intophpDocumentor:mainfrom
Conversation
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.
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.
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.