Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broader handling of glued roles. #61

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

JulienPalard
Copy link
Collaborator

Closes #60.

@JulienPalard
Copy link
Collaborator Author

Previously only glued s were found.

With this PR any character will trigger the rule.

@@ -165,7 +165,10 @@ def check_missing_space_after_role(file, lines, options=None):
# While this is not:
# The :literal:`:exc:`Exceptions``s
role_body = rf"([^`]|\s`+|\\`|:{rst.SIMPLENAME}:`([^`]|\s`+|\\`)+`)+"
suspicious_role = re.compile(f":{rst.SIMPLENAME}:`{role_body}`s")
allowed_after_role = " |" # '|' is allowed for roles in tables.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't commas and other punctuation allowed too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, I updated the list, does it looks better?

Comment on lines +148 to +151
ASCII_ALLOWED_BEFORE_INLINE_MARKUP = r"""-:/'"<(\[{"""
UNICODE_ALLOWED_BEFORE_INLINE_MARKUP = r"\p{Ps}\p{Pi}\p{Pf}\p{Pd}\p{Po}"
ASCII_ALLOWED_AFTER_INLINE_MARKUP = r"""-.,:;!?/'")\]}>"""
UNICODE_ALLOWED_AFTER_INLINE_MARKUP = r"\p{Pe}\p{Pi}\p{Pf}\p{Pd}\p{Po}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW all ASCII chars are technically already included in the Unicode categories, except for <> which have an Sm category. Even though they are redundant, I think it's ok since it's more explicit and it's easier to see what (ASCII) characters are allowed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this is a copy-paste from the spec: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules

I like copy-pasting from the spec.

@JulienPalard JulienPalard merged commit d2e3262 into sphinx-contrib:main Jul 20, 2023
18 checks passed
@JulienPalard JulienPalard deleted the mdk-space-after-role branch July 20, 2023 15:08
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.

Lack of space after Sphinx role not detected
2 participants