diff --git a/sphinxlint/checkers.py b/sphinxlint/checkers.py index 05afe352d..59d9ccf2b 100644 --- a/sphinxlint/checkers.py +++ b/sphinxlint/checkers.py @@ -197,10 +197,16 @@ def check_missing_space_after_role(file, lines, options=None): Bad: :exc:`Exception`s. Good: :exc:`Exceptions`\ s """ - for lno, line in enumerate(lines, start=1): - line = clean_paragraph(line) - for role in _SUSPICIOUS_ROLE.finditer(line): - yield lno, f"role missing (escaped) space after role: {role.group(0)!r}" + for paragraph_lno, paragraph in paragraphs(lines): + if paragraph.count("|") > 4: + continue # we don't handle tables yet. + paragraph = clean_paragraph(paragraph) + for role in _SUSPICIOUS_ROLE.finditer(paragraph): + error_offset = paragraph[: role.start()].count("\n") + yield ( + paragraph_lno + error_offset, + f"role missing (escaped) space after role: {role.group(0)!r}", + ) @checker(".rst", ".po") diff --git a/tests/fixtures/xpass/multiline-role-in-table.rst b/tests/fixtures/xpass/multiline-role-in-table.rst new file mode 100644 index 000000000..cfdcb512f --- /dev/null +++ b/tests/fixtures/xpass/multiline-role-in-table.rst @@ -0,0 +1,11 @@ +Math in Table +============= + ++-----------+---------------+---------------+ +| Shape | Area | Perimeter | ++===========+===============+===============+ +| Circle | :math:`\pi | :math:`2 \pi | +| | r^2` | r` | ++-----------+---------------+---------------+ +| Square | :math:`w^2` | :math:`4w` | ++-----------+---------------+---------------+