Skip to content

backend/rst: basic test_rst_reader unit test#7

Merged
stanislaw merged 1 commit intomasterfrom
rst-to-html
May 22, 2020
Merged

backend/rst: basic test_rst_reader unit test#7
stanislaw merged 1 commit intomasterfrom
rst-to-html

Conversation

@stanislaw
Copy link
Copy Markdown
Collaborator

No description provided.

@stanislaw stanislaw merged commit f0afad3 into master May 22, 2020
@stanislaw stanislaw deleted the rst-to-html branch May 22, 2020 12:06
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
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.

1 participant