Skip to content

Commit 4ec2ecb

Browse files
authored
Skip default role check for multiline roles in tables. (#65)
1 parent 33df562 commit 4ec2ecb

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

sphinxlint/checkers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def check_default_role(file, lines, options=None):
117117
if match:
118118
before_match = line[: match.start()]
119119
after_match = line[match.end() :]
120+
stripped_line = line.strip()
121+
if (stripped_line.startswith("|") and stripped_line.endswith("|") and
122+
stripped_line.count("|") >= 4 and "|" in match.group(0)):
123+
return # we don't handle tables yet.
120124
if re.search(rst.ROLE_TAG + "$", before_match):
121125
# It's not a default role: it starts with a tag.
122126
continue
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. expect: default role used (hint: for inline literals, use double backticks) (default-role)
2+
3+
In the following table there are a couple of default roles that should fail:
4+
5+
+-----------------+-------------------------------+----------------------------+
6+
| `French` | Julien Palard `@JulienPalard` | `GitHub <github_fr_>`_ |
7+
+-----------------+-------------------------------+----------------------------+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Links and default roles that span multiple lines in tables should be ignored:
2+
3+
+-----------------+-------------------------------+----------------------------+
4+
| `French (fr) | Julien Palard (`@JulienPalard | `GitHub <github_fr_>`_ |
5+
| <doc_fr_>`_ | on GitHub`) | |
6+
+-----------------+-------------------------------+----------------------------+

0 commit comments

Comments
 (0)