From b2a0efeb7e7aa06410e4f20345f0f1e1db89c499 Mon Sep 17 00:00:00 2001 From: danuker Date: Tue, 26 Jan 2021 12:12:32 +0200 Subject: [PATCH] Easier to edit wiki links, and more --- test/test_wiki_trac_rst_convert.py | 27 +++++++++++++++++---------- wiki_trac_rst_convert.py | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/test/test_wiki_trac_rst_convert.py b/test/test_wiki_trac_rst_convert.py index b3a09b1..0f4ef86 100644 --- a/test/test_wiki_trac_rst_convert.py +++ b/test/test_wiki_trac_rst_convert.py @@ -22,14 +22,14 @@ def test_empty(self): A file not ending in a newline character is not POSIX compliant, and may result in complaints from programs, like `git diff` - saying "\ No newline at end of file". + saying "No newline at end of file". https://stackoverflow.com/a/729795/235463 """ self.assertConvertedContent('\n', '') def test_newline(self): """ - A newline should not be appended another newline. + A newline will not get appended another newline. """ self.assertConvertedContent('\n', '\n') @@ -37,9 +37,16 @@ def test_removes_rst_wrapping(self): """ The Trac wiki syntax requires reStructuredText to be wrapped in {{{ #!rst }}} markers. - They must be removed from the output. + It removes the TracWiki RST armor markup from the output. """ self.assertConvertedContent('\n', '{{{#!rst}}}') + self.assertConvertedContent( + '\n', + '\n' + '{{{\n' + '#!rst' + '\n' + '}}}') def test_does_not_strip_content(self): """ @@ -56,7 +63,7 @@ def test_trac_rst_wiki_link(self): """ self.assertConvertedContent( - '`Requirements `__\n', + '``_\n', ':trac:`wiki:Requirements`' ) @@ -67,18 +74,18 @@ def test_trac_rst_wiki_link_to_page_in_subdir(self): """ self.assertConvertedContent( - '`General/FreeSoftwareUsage `__\n', + '``_\n', ':trac:`wiki:General/FreeSoftwareUsage`' ) def test_trac_rst_wiki_reverse_link(self): """ - Some Trac RST wiki links are "reversed", with the URL first and - the `:trac:` marker last. Handle them. + Trac RST wiki links that are "reversed", with the URL first and + the `:trac:` marker last are also handled. """ self.assertConvertedContent( - '`Infrastructure/Services/LAN#services `__\n', + '``_\n', '`wiki:Infrastructure/Services/LAN#services`:trac:' ) @@ -89,9 +96,9 @@ def test_several_trac_wiki_rst_links_with_content(self): """ self.assertConvertedContent( - '* `Requirements `__\n' + '* ``_\n' '* Some content\n' - '* `General/FreeSoftwareUsage `__' + '* ``_' ' List of free software used by Chevah Project.\n', '* :trac:`wiki:Requirements`\n' diff --git a/wiki_trac_rst_convert.py b/wiki_trac_rst_convert.py index da95167..2d6742b 100644 --- a/wiki_trac_rst_convert.py +++ b/wiki_trac_rst_convert.py @@ -65,7 +65,7 @@ def _trac_rst_wiki_to_github_links(text: str): for title in wiki_titles: text = re.sub( link_re, - rf'`\1 <{_wiki_url(title)}>`__', + rf'`<{_wiki_url(title)}>`_', text, 1 )