diff --git a/CHANGELOG.md b/CHANGELOG.md index 36148725..10f14cbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,14 @@ per-file diff commands. ### Fixed +- **`verify_pdf.py --ascii-dates` no longer reads a year-like run inside a longer number as a + date** - the year pattern had no digit boundaries, so `2000` inside `120000` or `12000` made + `Grew budget DKK 120000–200000` and `12000–15000 events/s` fail `/apply` Step 5d as + en-dashed date ranges, and the agent was sent to fix a "date argument" that does not exist. + The guide promises a numeric range with no year is left alone; now it is. `2016–2024` next to + a longer number is still caught. Two new `test_verify_pdf.py` cases; the numeric one fails + on the unbounded pattern. + - **`check_framework_version.py`'s git diff read no longer crashes on non-ASCII framework-file content** (`tools/check_framework_version.py`) - `run_git()` called `subprocess.run(text=True)` without an explicit `encoding`, so output decoded via the host diff --git a/tests/test_verify_pdf.py b/tests/test_verify_pdf.py index ee2680d6..8dc69740 100644 --- a/tests/test_verify_pdf.py +++ b/tests/test_verify_pdf.py @@ -99,6 +99,16 @@ class FindNonAsciiDateRangesTests(unittest.TestCase): # 05-cv-templates.md keeps `--` in prose ranges like EUR 600k--1M. self.assertEqual(find_non_ascii_date_ranges("EUR 600k\u20131M, 12\u201315 people"), []) + def test_year_like_digits_inside_a_longer_number_are_not_a_year(self): + # `2000` sits inside `120000`, `200000`, `12000`, `15000`: a budget or + # throughput range typed with `--` is not a date and must not fail 5d. + for text in ("Grew budget DKK 120000\u2013200000", "Scaled ingestion from 12000\u201315000 events/s"): + with self.subTest(text=text): + self.assertEqual(find_non_ascii_date_ranges(text), []) + + def test_a_standalone_year_next_to_a_longer_number_is_still_caught(self): + self.assertEqual(find_non_ascii_date_ranges("2016\u20132024 (120000 users)")[0][1], "\u2013") + def test_year_ending_a_line_is_not_joined_to_the_next_lines_dash(self): text = "Heading 1988-1994\n\u2013 note\n" self.assertEqual(find_non_ascii_date_ranges(text), []) diff --git a/tools/verify_pdf.py b/tools/verify_pdf.py index f75f03cf..b4abfef8 100644 --- a/tools/verify_pdf.py +++ b/tools/verify_pdf.py @@ -94,7 +94,9 @@ def normalize_text(text): # rest are the other Unicode dashes and the minus sign, which a parser that splits # a range only on U+002D treats the same way. NON_ASCII_DASHES = "\u2010\u2011\u2012\u2013\u2014\u2015\u2212" -_YEAR = r"(?:19|20)\d{2}" +# A year is four digits standing alone: without the digit boundaries, `2000` +# inside `120000` or `12000` made a budget or throughput range read as a date. +_YEAR = r"(?