Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2753eb

Browse files
hugovkYuki Kobayashi
andauthored
Fix to skip missing-space-after-role check in tables (#143)
Co-authored-by: Yuki Kobayashi <[email protected]>
1 parent 0e9f6fc commit a2753eb

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

sphinxlint/checkers.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,16 @@ def check_missing_space_after_role(file, lines, options=None):
197197
Bad: :exc:`Exception`s.
198198
Good: :exc:`Exceptions`\ s
199199
"""
200-
for lno, line in enumerate(lines, start=1):
201-
line = clean_paragraph(line)
202-
for role in _SUSPICIOUS_ROLE.finditer(line):
203-
yield lno, f"role missing (escaped) space after role: {role.group(0)!r}"
200+
for paragraph_lno, paragraph in paragraphs(lines):
201+
if paragraph.count("|") > 4:
202+
continue # we don't handle tables yet.
203+
paragraph = clean_paragraph(paragraph)
204+
for role in _SUSPICIOUS_ROLE.finditer(paragraph):
205+
error_offset = paragraph[: role.start()].count("\n")
206+
yield (
207+
paragraph_lno + error_offset,
208+
f"role missing (escaped) space after role: {role.group(0)!r}",
209+
)
204210

205211

206212
@checker(".rst", ".po")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Math in Table
2+
=============
3+
4+
+-----------+---------------+---------------+
5+
| Shape | Area | Perimeter |
6+
+===========+===============+===============+
7+
| Circle | :math:`\pi | :math:`2 \pi |
8+
| | r^2` | r` |
9+
+-----------+---------------+---------------+
10+
| Square | :math:`w^2` | :math:`4w` |
11+
+-----------+---------------+---------------+

0 commit comments

Comments
 (0)