Skip to content

Commit

Permalink
👌 Make needtable titles more permissive (#1102)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chrisjsewell authored Feb 15, 2024
1 parent 050bec7 commit e9582ed
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sphinx_needs/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
""",
}

TITLE_REGEX = r'([\w]+) as "([\w ]+)"'
TITLE_REGEX = r'([^\s]+) as "([^"]+)"'


NEED_DEFAULT_OPTIONS: Dict[str, Any] = {
Expand Down
1 change: 1 addition & 0 deletions tests/doc_test/doc_needtable/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"github",
"value",
"unit",
"special-chars!",
]

needs_string_links = {
Expand Down
3 changes: 2 additions & 1 deletion tests/doc_test/doc_needtable/test_titles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/test_needtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,5 @@ def test_doc_needtable_titles(test_app):
html = Path(app.outdir, "test_titles.html").read_text()
assert '<th class="head"><p>Headline</p></th>' in html
assert '<th class="head"><p>To this need123</p></th>' in html
assert '<th class="head"><p>Special Characters!</p></th>' in html
assert '<td class="needs_special-chars!"><p>special-chars value</p></td>' in html

0 comments on commit e9582ed

Please sign in to comment.