-
Notifications
You must be signed in to change notification settings - Fork 507
Open
Description
I recently started using --ignore-multiline-regex:
$ codespell -h
...
--ignore-multiline-regex IGNORE_MULTILINE_REGEX
regular expression that is used to ignore text that may span
multi-line regions. The regex is run with re.DOTALL. For
example to allow skipping of regions of Python code using
begin/end comments one could use: --ignore-multiline-regex '#
codespell:ignore-begin *\n.*# codespell:ignore-end *\n'.
Defaults to empty/disabled.
I started out with this simple setup in setup.cfg:
# How to ignore blocks of code.
ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end
Soon I found out that the matching is greedy and that therefore in this example:
/* codespell:ignore-begin */
/* Ignore this: usuable. */
/* codespell:ignore-end */
/* Don't ignore this: usuable. */
/* codespell:ignore-begin */
/* Ignore that: usuable. */
/* codespell:ignore-end */
codespell ignores the "Don't ignore this" line.
I fixed this by doing:
ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end
ignore-multiline-regex = codespell:ignore-begin.*?codespell:ignore-end
We should do the same in the example shown by codespell -h.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels