From 68b4eff3b1d4f1989384b59f762c8165271c1955 Mon Sep 17 00:00:00 2001 From: Tobias Deiminger Date: Sun, 30 Jun 2024 23:52:27 +0200 Subject: [PATCH] Add parentheses to UID regex Follow up to #1902. --- strictdoc/backend/sdoc/grammar/grammar.py | 2 +- .../strictdoc/backend/sdoc/test_dsl_passthrough.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/strictdoc/backend/sdoc/grammar/grammar.py b/strictdoc/backend/sdoc/grammar/grammar.py index c7827eab2..201b7265b 100644 --- a/strictdoc/backend/sdoc/grammar/grammar.py +++ b/strictdoc/backend/sdoc/grammar/grammar.py @@ -1,4 +1,4 @@ -REGEX_UID = r"([\w]+[\w\-. ]*)" +REGEX_UID = r"([\w]+[\w()\-. ]*)" NEGATIVE_MULTILINE_STRING_START = "(?!>>>\n)" NEGATIVE_MULTILINE_STRING_END = "(?!^<<<)" diff --git a/tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py b/tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py index 95c048f68..95055afd5 100644 --- a/tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py +++ b/tests/unit/strictdoc/backend/sdoc/test_dsl_passthrough.py @@ -217,13 +217,13 @@ def test_022_requirement_uid_and_link(): TITLE: Test Doc [REQUIREMENT] -UID: With spaces and _ and - and . and non latin 特点 +UID: With spaces and (_-.) and non latin 特点 STATEMENT: >>> This is a statement. [TEXT] STATEMENT: >>> -[LINK: With spaces and _ and - and . and non latin 特点] +[LINK: With spaces and (_-.) and non latin 特点] <<< """.lstrip() @@ -976,7 +976,7 @@ def test_edge_case_03_uid_present_but_empty_with_space_character(): _ = reader.read(input_sdoc) assert exc_info.type is TextXSyntaxError - assert "Expected '([\\w]+[\\w\\-. ]*)'" in exc_info.value.args[0].decode( + assert "Expected '([\\w]+[\\w()\\-. ]*)'" in exc_info.value.args[0].decode( "utf-8" ) @@ -997,7 +997,7 @@ def test_edge_case_04_uid_present_but_empty_with_two_space_characters(): _ = reader.read(input_sdoc) assert exc_info.type is TextXSyntaxError - assert "Expected '([\\w]+[\\w\\-. ]*)'" in exc_info.value.args[0].decode( + assert "Expected '([\\w]+[\\w()\\-. ]*)'" in exc_info.value.args[0].decode( "utf-8" ) @@ -1021,8 +1021,8 @@ def test_edge_case_10_empty_multiline_field(): assert ( "Expected '^\\[ANCHOR: ' or '[LINK: ' or " "'(?ms)(?!^<<<)(?!^\\[\\/FREETEXT\\]\\n)(?!\\[LINK: " - "([\\w]+[\\w\\-. ]*))(?!^\\[ANCHOR: " - "([\\w]+[\\w\\-. ]*)).'" in exc_info.value.args[0].decode("utf-8") + "([\\w]+[\\w()\\-. ]*))(?!^\\[ANCHOR: " + "([\\w]+[\\w()\\-. ]*)).'" in exc_info.value.args[0].decode("utf-8") )