diff --git a/sphinxlint/checkers.py b/sphinxlint/checkers.py index 05afe352d..4f4dbe9fd 100644 --- a/sphinxlint/checkers.py +++ b/sphinxlint/checkers.py @@ -301,6 +301,19 @@ def check_role_with_double_backticks(file, lines, options=None): ) +@checker(".rst", ".po") +def check_role_with_extra_backtick(filename, lines, options): + """Check for extra backtick in roles. + + Bad: :func:`foo`` + Bad: :func:``foo` + Good: :func:`foo` + """ + for lno, line in enumerate(lines, start=1): + for match in rst.ROLE_WITH_EXTRA_BACKTICK_RE.finditer(line): + yield lno, f"Extra backtick in role: {match.group(0).strip()!r}" + + @checker(".rst", ".po") def check_missing_space_before_role(file, lines, options=None): """Search for missing spaces before roles. diff --git a/sphinxlint/rst.py b/sphinxlint/rst.py index 4c8c02617..5ca60c3ba 100644 --- a/sphinxlint/rst.py +++ b/sphinxlint/rst.py @@ -249,6 +249,13 @@ def inline_markup_gen(start_string, end_string, extra_allowed_before=""): # :const:`None` DOUBLE_BACKTICK_ROLE_RE = re.compile(rf"(?