diff --git a/src/doc8/checks.py b/src/doc8/checks.py index a43d1a7..8ece687 100644 --- a/src/doc8/checks.py +++ b/src/doc8/checks.py @@ -61,11 +61,13 @@ def report_iter(self, line): class CheckCarriageReturn(ContentCheck): + _CARRIAGE_RETURN_REGEX = re.compile(rb"\r(?!\n)") REPORTS = frozenset(["D004"]) def report_iter(self, parsed_file): for i, line in enumerate(parsed_file.lines): - if b"\r" in line: + matches = self._CARRIAGE_RETURN_REGEX.findall(line) + if len(matches) != 0: yield (i + 1, "D004", "Found literal carriage return")