From e9582edb45ffbb7bb90296d910b7c00352d7c800 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 15 Feb 2024 14:10:36 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20Make=20needtable=20titles=20more?= =?UTF-8?q?=20permissive=20(#1102)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For `key as "title"` columns, the regex has been changed, to allow for the key to contain anything except whitespace characters, and the title to contain anything except the `"` character --- sphinx_needs/defaults.py | 2 +- tests/doc_test/doc_needtable/conf.py | 1 + tests/doc_test/doc_needtable/test_titles.rst | 3 ++- tests/test_needtable.py | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sphinx_needs/defaults.py b/sphinx_needs/defaults.py index c23903fcd..2e7a11913 100644 --- a/sphinx_needs/defaults.py +++ b/sphinx_needs/defaults.py @@ -199,7 +199,7 @@ """, } -TITLE_REGEX = r'([\w]+) as "([\w ]+)"' +TITLE_REGEX = r'([^\s]+) as "([^"]+)"' NEED_DEFAULT_OPTIONS: Dict[str, Any] = { diff --git a/tests/doc_test/doc_needtable/conf.py b/tests/doc_test/doc_needtable/conf.py index 585e4438d..73fd61077 100644 --- a/tests/doc_test/doc_needtable/conf.py +++ b/tests/doc_test/doc_needtable/conf.py @@ -23,6 +23,7 @@ "github", "value", "unit", + "special-chars!", ] needs_string_links = { diff --git a/tests/doc_test/doc_needtable/test_titles.rst b/tests/doc_test/doc_needtable/test_titles.rst index e1a598685..75db1cca4 100644 --- a/tests/doc_test/doc_needtable/test_titles.rst +++ b/tests/doc_test/doc_needtable/test_titles.rst @@ -12,7 +12,8 @@ TEST Titles .. spec:: need 3 :id: titles_003 :links: titles_001 + :special-chars!: special-chars value .. needtable:: - :columns: id;title as "Headline" ;outgoing as "Links"; incoming as "To this need123";status;tags as "My Tags" + :columns: id;title as "Headline" ;outgoing as "Links"; incoming as "To this need123";status;tags as "My Tags";special-chars! as "Special Characters!" :style: table diff --git a/tests/test_needtable.py b/tests/test_needtable.py index 40bb9b33d..211be333e 100644 --- a/tests/test_needtable.py +++ b/tests/test_needtable.py @@ -149,3 +149,5 @@ def test_doc_needtable_titles(test_app): html = Path(app.outdir, "test_titles.html").read_text() assert '

Headline

' in html assert '

To this need123

' in html + assert '

Special Characters!

' in html + assert '

special-chars value

' in html