Conversation
haxtibal
added a commit
to haxtibal/strictdoc
that referenced
this pull request
Jul 1, 2024
When rendering rst fragments to HTML, InlineLinks are first converted to ':rawhtml:`<a href="#TGT">link text</a>`', then are rendered to HTML by docutils publish_parts. That rawhtml construct is a special form of inline markup, for which rst defines recognition rules [1]. strictdoc-project#7 says Inline markup end-strings must end a text block or be immediately followed by whitespace, one of the ASCII characters - . , : ; ! ? \ / ' " ) ] } > or a similar non-ASCII punctuation character. [20] That's why LINK followed by character produces error or odd HTML. To get around, we can use rst's escaping mechanism [2]. Escaped non-white characters are prevented from playing a role in any markup interpretation. The escaped character represents the character itself. The code change detects if inline links are followed by whitespace characters and adds in a backslash if so. This works also for the punctuation cases. Fixes strictdoc-project#1907. [1] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules [2] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#escaping-mechanism
haxtibal
added a commit
to haxtibal/strictdoc
that referenced
this pull request
Jul 2, 2024
When rendering rst fragments to HTML, InlineLinks are first converted to ':rawhtml:`<a href="#TGT">link text</a>`', then are rendered to HTML by docutils publish_parts. That rawhtml construct is a special form of inline markup, for which rst defines recognition rules [1]. strictdoc-project#7 says Inline markup end-strings must end a text block or be immediately followed by whitespace, one of the ASCII characters - . , : ; ! ? \ / ' " ) ] } > or a similar non-ASCII punctuation character. [20] That's why LINK followed by character produces error or odd HTML. To get around, we can use rst's escaping mechanism [2]. Escaped non-white characters are prevented from playing a role in any markup interpretation. The escaped character represents the character itself. The code change detects if an inline links is followed by non-whitespace or non-punctuation character and adds in a backslash if so. Punctuation characters in the non-latin range are not explicitely checked and thus also joined with "\". This is unnecessary from RST syntax point of view, but doesn't hurt as it just maps them to themselves. Fixes strictdoc-project#1907. [1] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules [2] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#escaping-mechanism
haxtibal
added a commit
to haxtibal/strictdoc
that referenced
this pull request
Jul 2, 2024
When rendering rst fragments to HTML, InlineLinks are first converted to ':rawhtml:`<a href="#TGT">link text</a>`', then are rendered to HTML by docutils publish_parts. That rawhtml construct is a special form of inline markup, for which rst defines recognition rules [1]. strictdoc-project#7 says Inline markup end-strings must end a text block or be immediately followed by whitespace, one of the ASCII characters - . , : ; ! ? \ / ' " ) ] } > or a similar non-ASCII punctuation character. [20] That's why LINK followed by character produces error or odd HTML. To get around, we can use rst's escaping mechanism [2]. Escaped non-white characters are prevented from playing a role in any markup interpretation. The escaped character represents the character itself. The code change detects if an inline links is followed by non-whitespace or non-punctuation character and adds in a backslash if so. Punctuation characters in the non-latin range are not explicitly checked and thus also joined with "\". This is unnecessary from RST syntax point of view, but doesn't hurt as it just maps them to themselves. Fixes strictdoc-project#1907. [1] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules [2] https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#escaping-mechanism
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.
No description provided.