From 1cfbdb4f0777e9cdf78a862d4c5e6dd2240b8579 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Sat, 6 Feb 2021 19:44:23 +0200 Subject: [PATCH] rst-backticks: ignore 4-space indented code blocks --- .pre-commit-hooks.yaml | 2 +- tests/hooks_test.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 6f23f4d..f355a57 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -50,7 +50,7 @@ - id: rst-backticks name: rst ``code`` is two backticks description: 'Detect common mistake of using single backticks when writing rst' - entry: '(^| )`[^`]+`([^_]|$)' + entry: '^(?! ).*(^| )`[^`]+`([^_]|$)' language: pygrep types: [rst] - id: rst-directive-colons diff --git a/tests/hooks_test.py b/tests/hooks_test.py index d2655c9..b13b56a 100644 --- a/tests/hooks_test.py +++ b/tests/hooks_test.py @@ -133,6 +133,8 @@ def test_python_no_log_warn_negative(s): 'i like `_`', '`a`', '`cd`', + ' `indented` literal block', + '> quoted `literal` block', ), ) def test_python_rst_backticks_positive(s): @@ -147,6 +149,7 @@ def test_python_rst_backticks_positive(s): 'i like `kitty`_', '``b``', '``ef``', + ' indented `literal` block', ), ) def test_python_rst_backticks_negative(s):