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

RST: Add hook to find inline code touching normal text #30

Merged
merged 1 commit into from Aug 14, 2020

Conversation

@hugovk
Copy link
Contributor

@hugovk hugovk commented Aug 12, 2020

I recently used rst-backticks to find and fix some PEPs (python/peps#1554) and am planning to add it as a pre-commit linter on the CI.

I also fixed some related RST problems (python/peps#1560) where inline code touches normal text. This sort of stuff is allowed in Markdown but not reStructuredText:

-``PyMem_Realloc()`` indirectly call``PyObject_Malloc()`` and
+``PyMem_Realloc()`` indirectly call ``PyObject_Malloc()`` and

-This PEP proposes that ``bytes`` and ``bytearray``gain an optimised
+This PEP proposes that ``bytes`` and ``bytearray`` gain an optimised

-Reading this we first see the``break``, which obviously applies to
+Reading this we first see the ``break``, which obviously applies to

-for using``long_description`` and a corresponding
+for using ``long_description`` and a corresponding

Guido suggested a linter for this too (python/peps#1560 (review)), and as I used grep to find these:

$ git grep "[A-Za-z0-9]\`\`[A-Za-z0-9]"
pep-0445.txt:``PyMem_Realloc()`` indirectly call``PyObject_Malloc()`` and
pep-0467.txt:This PEP proposes that ``bytes`` and ``bytearray``gain an optimised
pep-0548.rst:Reading this we first see the``break``, which obviously applies to
pep-0621.rst:for using``long_description`` and a corresponding

then pygrep-hooks makes a good fit!

I didn't find anything in the spec where "alphanumeric double-backticks alphanumeric" is allowed so I think it's safe to add:


Naming things: always hard, feedback welcome for improvements on rst-inline-touching-normal.

Tests: I added the four real problems I found in the PEPs, plus some simplified versions. Let me know if you'd prefer only the simplified versions.

Copy link
Member

@asottile asottile left a comment

looks good, just a small comment

.pre-commit-hooks.yaml Outdated Show resolved Hide resolved
@asottile asottile force-pushed the hugovk:rst-inline-touching-normal branch from 22cbaa5 to 4bae8e6 Aug 14, 2020
Copy link
Member

@asottile asottile left a comment

@asottile asottile merged commit 0fcd210 into pre-commit:master Aug 14, 2020
1 check passed
1 check passed
pre-commit.pygrep-hooks #20200814.1 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.