From 4ea16046d39483d470af2594ca5ed5ff1593828a Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Fri, 5 Jan 2018 15:49:14 +1300 Subject: [PATCH 1/7] Update markdown from 2.6.10 to 2.6.11 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d79b89a3..4202737a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # Required dependencies for Verto (installed automatically in setup.py) -markdown==2.6.10 +markdown==2.6.11 Jinja2==2.10 python-slugify==1.2.4 setuptools==38.2.5 From e21b78ea4dc24dc3619231757023f988bb6ba0ab Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Sat, 6 Jan 2018 03:54:16 +1300 Subject: [PATCH 2/7] Update setuptools from 38.2.5 to 38.4.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d79b89a3..5d676257 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ markdown==2.6.10 Jinja2==2.10 python-slugify==1.2.4 -setuptools==38.2.5 +setuptools==38.4.0 # Required dependencies for building documentation sphinx==1.6.5 From 60cce69663206297cd128e1f3b0b4876df7e3a18 Mon Sep 17 00:00:00 2001 From: pyup-bot Date: Tue, 9 Jan 2018 11:23:11 +1300 Subject: [PATCH 3/7] Update sphinx from 1.6.5 to 1.6.6 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d79b89a3..a99f685e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,5 +5,5 @@ python-slugify==1.2.4 setuptools==38.2.5 # Required dependencies for building documentation -sphinx==1.6.5 +sphinx==1.6.6 sphinx_rtd_theme==0.2.4 From a7c54ca42efe1832b51f657136a5b671c4331802 Mon Sep 17 00:00:00 2001 From: Jack Morgan Date: Mon, 15 Jan 2018 09:35:23 +1300 Subject: [PATCH 4/7] Panel titles and subtitles do not catch punctation (fixes #267) Also changes regular expression to match heading syntax, where a whitespace character is optional after defining the heading level. Also adds test to heading processor for checking it works when no whitespace character is given. --- verto/processors/PanelBlockProcessor.py | 8 ++-- verto/tests/HeadingTest.py | 39 ++++++++++++++++++- verto/tests/PanelTest.py | 35 +++++++++++++++-- verto/tests/assets/heading/no_whitespace.md | 5 +++ .../heading/no_whitespace_expected.html | 18 +++++++++ ...e.md => heading_subtitle_no_whitespace.md} | 2 +- ...ading_subtitle_no_whitespace_expected.html | 8 ++++ .../assets/panel/heading_with_punctation.md | 7 ++++ .../heading_with_punctation_expected.html | 8 ++++ .../heading_with_subtitle_with_punctation.md | 9 +++++ ...ith_subtitle_with_punctation_expected.html | 8 ++++ 11 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 verto/tests/assets/heading/no_whitespace.md create mode 100644 verto/tests/assets/heading/no_whitespace_expected.html rename verto/tests/assets/panel/{incorrect_heading_incorrect_subtitle.md => heading_subtitle_no_whitespace.md} (52%) create mode 100644 verto/tests/assets/panel/heading_subtitle_no_whitespace_expected.html create mode 100644 verto/tests/assets/panel/heading_with_punctation.md create mode 100644 verto/tests/assets/panel/heading_with_punctation_expected.html create mode 100644 verto/tests/assets/panel/heading_with_subtitle_with_punctation.md create mode 100644 verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html diff --git a/verto/processors/PanelBlockProcessor.py b/verto/processors/PanelBlockProcessor.py index d677c464..0562706f 100644 --- a/verto/processors/PanelBlockProcessor.py +++ b/verto/processors/PanelBlockProcessor.py @@ -30,19 +30,19 @@ def custom_parsing(self, content_blocks, argument_values): blocks = [] argument = 'title' - title_r = re.compile(r'(^|\n)# ((\w| )*)(?P)') + title_r = re.compile(r'^#(?!#+)\s?(?P.*?)$') title = title_r.search(content_blocks[0]) if title: - extra_args[argument] = title.groups()[1] + extra_args[argument] = title.group(argument) else: raise PanelMissingTitleError(self.processor, argument) argument = 'subtitle' if argument_values.get(argument) == 'true': - subtitle_r = re.compile(r'(^|\n)## ((\w| )*)(?P<args>)') + subtitle_r = re.compile(r'^##(?!#+)\s?(?P<subtitle>.*?)$') subtitle = subtitle_r.search(content_blocks[1]) if subtitle: - extra_args[argument] = subtitle.groups()[1] + extra_args[argument] = subtitle.group(argument) blocks = content_blocks[2:] else: raise PanelMissingSubtitleError(self.processor, argument) diff --git a/verto/tests/HeadingTest.py b/verto/tests/HeadingTest.py index 7a1e640a..a77bcbbd 100644 --- a/verto/tests/HeadingTest.py +++ b/verto/tests/HeadingTest.py @@ -40,6 +40,41 @@ def test_example_blank(self): tree = self.verto_extension.get_heading_tree() self.assertIsNone(tree) + def test_no_whitespace(self): + '''An example of usage with no whitespace between heading level and text. + ''' + test_string = self.read_test_file(self.processor_name, 'no_whitespace.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, True, True], [HeadingBlockProcessor(self.ext, self.md.parser).test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'no_whitespace_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + + tree = self.verto_extension.get_heading_tree() + expected_tree = (HeadingNode(title='This is an H1', + title_slug='this-is-an-h1', + level=1, + children=( + HeadingNode( + title='This is an H2', + title_slug='this-is-an-h2', + level=2, + children=( + HeadingNode( + title='This is an H6', + title_slug='this-is-an-h6', + level=6, + children=() + ), + ) + ), + ) + ), + ) + self.assertTupleEqual(tree, expected_tree) + def test_single_heading(self): '''Checks the simplist case of a single heading. ''' @@ -127,7 +162,7 @@ def test_multiple_roots_zero_level(self): #~ def test_doc_example_basic(self): - '''An example of simplistic useage. + '''An example of simplistic usage. ''' test_string = self.read_test_file(self.processor_name, 'doc_example_basic_usage.md') blocks = self.to_blocks(test_string) @@ -163,7 +198,7 @@ def test_doc_example_basic(self): def test_doc_example_override_html(self): - '''An example of complex useage, involving multiple H1s + '''An example of complex usage, involving multiple H1s and shows html overriding. ''' test_string = self.read_test_file(self.processor_name, 'doc_example_override_html.md') diff --git a/verto/tests/PanelTest.py b/verto/tests/PanelTest.py index d3f4b4f6..76e531f2 100644 --- a/verto/tests/PanelTest.py +++ b/verto/tests/PanelTest.py @@ -39,6 +39,18 @@ def test_heading_no_subtitle(self): expected_string = self.read_test_file(self.processor_name, 'heading_no_subtitle_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) + def test_heading_with_punctation(self): + '''Tests that a heading is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_with_punctation.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_with_punctation_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + def test_heading_subtitle_false(self): '''Tests that a heading is parsed correctly ''' @@ -75,6 +87,18 @@ def test_heading_with_subtitle(self): expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) + def test_heading_with_subtitle_with_punctation(self): + '''Tests that both a heading and subtitle is parsed correctly + ''' + test_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctation.md') + blocks = self.to_blocks(test_string) + + self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) + + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctation_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) + def test_heading_with_subtitle_h2_heading_in_panel(self): '''Tests that both a heading and subtitle is parsed correctly ''' @@ -157,15 +181,18 @@ def test_heading_incorrect_subtitle(self): self.assertRaises(PanelMissingSubtitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) - def test_incorrect_heading_incorrect_subtitle(self): - '''Tests that correct error raised when heading and subtitle are incorrect + def test_heading_subtitle_no_whitespace(self): + '''Tests that heading and subtitle render correctly when no + whitespace is given between heading level and text. ''' - test_string = self.read_test_file(self.processor_name, 'incorrect_heading_incorrect_subtitle.md') + test_string = self.read_test_file(self.processor_name, 'heading_subtitle_no_whitespace.md') blocks = self.to_blocks(test_string) self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) - self.assertRaises(PanelMissingTitleError, lambda x: markdown.markdown(x, extensions=[self.verto_extension]), test_string) + converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) + expected_string = self.read_test_file(self.processor_name, 'heading_subtitle_no_whitespace_expected.html', strip=True) + self.assertEqual(expected_string, converted_test_string) def test_parses_blank(self): '''Tests that a blank panel is processed with empty content. diff --git a/verto/tests/assets/heading/no_whitespace.md b/verto/tests/assets/heading/no_whitespace.md new file mode 100644 index 00000000..8e17f83c --- /dev/null +++ b/verto/tests/assets/heading/no_whitespace.md @@ -0,0 +1,5 @@ +#This is an H1 + +##This is an H2 + +######This is an H6 diff --git a/verto/tests/assets/heading/no_whitespace_expected.html b/verto/tests/assets/heading/no_whitespace_expected.html new file mode 100644 index 00000000..c70efa56 --- /dev/null +++ b/verto/tests/assets/heading/no_whitespace_expected.html @@ -0,0 +1,18 @@ +<h1 id="this-is-an-h1"> +<span class="section_number"> +{{ chapter.number }}. +</span> +This is an H1 +</h1> +<h2 id="this-is-an-h2"> +<span class="section_number"> +{{ chapter.number }}.1. +</span> +This is an H2 +</h2> +<h6 id="this-is-an-h6"> +<span class="section_number"> +{{ chapter.number }}.1.0.0.0.1. +</span> +This is an H6 +</h6> diff --git a/verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md b/verto/tests/assets/panel/heading_subtitle_no_whitespace.md similarity index 52% rename from verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md rename to verto/tests/assets/panel/heading_subtitle_no_whitespace.md index d94597e2..28e4eab8 100644 --- a/verto/tests/assets/panel/incorrect_heading_incorrect_subtitle.md +++ b/verto/tests/assets/panel/heading_subtitle_no_whitespace.md @@ -4,6 +4,6 @@ ##Subtitle -This panel does have a subtitle...but both headings are incorrect +Panel text. {panel end} diff --git a/verto/tests/assets/panel/heading_subtitle_no_whitespace_expected.html b/verto/tests/assets/panel/heading_subtitle_no_whitespace_expected.html new file mode 100644 index 00000000..aa01322c --- /dev/null +++ b/verto/tests/assets/panel/heading_subtitle_no_whitespace_expected.html @@ -0,0 +1,8 @@ +<div class="panel panel-note"> +<div class="panel-header"> +<strong>Heading:</strong> Subtitle +</div> +<div class="panel-body"> +<p>Panel text.</p> +</div> +</div> diff --git a/verto/tests/assets/panel/heading_with_punctation.md b/verto/tests/assets/panel/heading_with_punctation.md new file mode 100644 index 00000000..eb3e907b --- /dev/null +++ b/verto/tests/assets/panel/heading_with_punctation.md @@ -0,0 +1,7 @@ +{panel type="note"} + +# crwdns8254:0crwdne8254:0 + +crwdns8255:0crwdne8255:0 crwdns8256:0crwdne8256:0 crwdns8257:0crwdne8257:0 crwdns8258:0crwdne8258:0 + +{panel end} diff --git a/verto/tests/assets/panel/heading_with_punctation_expected.html b/verto/tests/assets/panel/heading_with_punctation_expected.html new file mode 100644 index 00000000..75c35936 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_punctation_expected.html @@ -0,0 +1,8 @@ +<div class="panel panel-note"> +<div class="panel-header"> +<strong>crwdns8254:0crwdne8254:0</strong> +</div> +<div class="panel-body"> +<p>crwdns8255:0crwdne8255:0 crwdns8256:0crwdne8256:0 crwdns8257:0crwdne8257:0 crwdns8258:0crwdne8258:0</p> +</div> +</div> diff --git a/verto/tests/assets/panel/heading_with_subtitle_with_punctation.md b/verto/tests/assets/panel/heading_with_subtitle_with_punctation.md new file mode 100644 index 00000000..3a144092 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle_with_punctation.md @@ -0,0 +1,9 @@ +{panel type="note" subtitle="true"} + +# Heading + +## crwdns8299:0crwdne8299:0 + +This panel does have a subtitle! + +{panel end} diff --git a/verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html b/verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html new file mode 100644 index 00000000..ffb61b93 --- /dev/null +++ b/verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html @@ -0,0 +1,8 @@ +<div class="panel panel-note"> +<div class="panel-header"> +<strong>Heading:</strong> crwdns8299:0crwdne8299:0 +</div> +<div class="panel-body"> +<p>This panel does have a subtitle!</p> +</div> +</div> From c4712657106ddbaffe7d7fa63669cd5e5b3281bb Mon Sep 17 00:00:00 2001 From: Jack Morgan <jackmorgannz@gmail.com> Date: Mon, 15 Jan 2018 09:45:58 +1300 Subject: [PATCH 5/7] Increment version number to 0.7.2 --- verto/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verto/__init__.py b/verto/__init__.py index 89639e69..f382f833 100644 --- a/verto/__init__.py +++ b/verto/__init__.py @@ -1,4 +1,4 @@ # flake8: noqa from .Verto import Verto -__version__ = '0.7.1' +__version__ = '0.7.2' From 20f731458225c9b95cdaccd4383570cd4bc7b643 Mon Sep 17 00:00:00 2001 From: Jack Morgan <jackmorgannz@gmail.com> Date: Mon, 15 Jan 2018 09:53:12 +1300 Subject: [PATCH 6/7] Add changelog for 0.7.2 --- docs/source/changelog.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 1ddf618f..d99c6769 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -1,6 +1,16 @@ Changelog ####################################### +0.7.2 +======================================= + +- Fix bug where :doc:`processors/panel` processor does not handle punctation characters in titles and subtitles. +- Dependency updates: + + - Update ``markdown`` to 2.6.11. + - Update ``setuptools`` to 38.4.0. + - Update ``sphinx`` to 1.6.6. + 0.7.1 ======================================= From afcf20c21c1ae608347f930eda74b16d982966eb Mon Sep 17 00:00:00 2001 From: Jack Morgan <jackmorgannz@gmail.com> Date: Mon, 15 Jan 2018 09:58:48 +1300 Subject: [PATCH 7/7] Fix typo 'punctation' to 'punctuation' --- docs/source/changelog.rst | 2 +- verto/tests/PanelTest.py | 12 ++++++------ ...ith_punctation.md => heading_with_punctuation.md} | 0 ...d.html => heading_with_punctuation_expected.html} | 0 ....md => heading_with_subtitle_with_punctuation.md} | 0 ...ing_with_subtitle_with_punctuation_expected.html} | 0 6 files changed, 7 insertions(+), 7 deletions(-) rename verto/tests/assets/panel/{heading_with_punctation.md => heading_with_punctuation.md} (100%) rename verto/tests/assets/panel/{heading_with_punctation_expected.html => heading_with_punctuation_expected.html} (100%) rename verto/tests/assets/panel/{heading_with_subtitle_with_punctation.md => heading_with_subtitle_with_punctuation.md} (100%) rename verto/tests/assets/panel/{heading_with_subtitle_with_punctation_expected.html => heading_with_subtitle_with_punctuation_expected.html} (100%) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index d99c6769..f08c8f3b 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -4,7 +4,7 @@ Changelog 0.7.2 ======================================= -- Fix bug where :doc:`processors/panel` processor does not handle punctation characters in titles and subtitles. +- Fix bug where :doc:`processors/panel` processor does not handle punctuation characters in titles and subtitles. - Dependency updates: - Update ``markdown`` to 2.6.11. diff --git a/verto/tests/PanelTest.py b/verto/tests/PanelTest.py index 76e531f2..76c4344b 100644 --- a/verto/tests/PanelTest.py +++ b/verto/tests/PanelTest.py @@ -39,16 +39,16 @@ def test_heading_no_subtitle(self): expected_string = self.read_test_file(self.processor_name, 'heading_no_subtitle_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) - def test_heading_with_punctation(self): + def test_heading_with_punctuation(self): '''Tests that a heading is parsed correctly ''' - test_string = self.read_test_file(self.processor_name, 'heading_with_punctation.md') + test_string = self.read_test_file(self.processor_name, 'heading_with_punctuation.md') blocks = self.to_blocks(test_string) self.assertListEqual([True, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'heading_with_punctation_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'heading_with_punctuation_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) def test_heading_subtitle_false(self): @@ -87,16 +87,16 @@ def test_heading_with_subtitle(self): expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) - def test_heading_with_subtitle_with_punctation(self): + def test_heading_with_subtitle_with_punctuation(self): '''Tests that both a heading and subtitle is parsed correctly ''' - test_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctation.md') + test_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctuation.md') blocks = self.to_blocks(test_string) self.assertListEqual([True, False, False, False, True], [self.block_processor.test(blocks, block) for block in blocks], msg='"{}"'.format(test_string)) converted_test_string = markdown.markdown(test_string, extensions=[self.verto_extension]) - expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctation_expected.html', strip=True) + expected_string = self.read_test_file(self.processor_name, 'heading_with_subtitle_with_punctuation_expected.html', strip=True) self.assertEqual(expected_string, converted_test_string) def test_heading_with_subtitle_h2_heading_in_panel(self): diff --git a/verto/tests/assets/panel/heading_with_punctation.md b/verto/tests/assets/panel/heading_with_punctuation.md similarity index 100% rename from verto/tests/assets/panel/heading_with_punctation.md rename to verto/tests/assets/panel/heading_with_punctuation.md diff --git a/verto/tests/assets/panel/heading_with_punctation_expected.html b/verto/tests/assets/panel/heading_with_punctuation_expected.html similarity index 100% rename from verto/tests/assets/panel/heading_with_punctation_expected.html rename to verto/tests/assets/panel/heading_with_punctuation_expected.html diff --git a/verto/tests/assets/panel/heading_with_subtitle_with_punctation.md b/verto/tests/assets/panel/heading_with_subtitle_with_punctuation.md similarity index 100% rename from verto/tests/assets/panel/heading_with_subtitle_with_punctation.md rename to verto/tests/assets/panel/heading_with_subtitle_with_punctuation.md diff --git a/verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html b/verto/tests/assets/panel/heading_with_subtitle_with_punctuation_expected.html similarity index 100% rename from verto/tests/assets/panel/heading_with_subtitle_with_punctation_expected.html rename to verto/tests/assets/panel/heading_with_subtitle_with_punctuation_expected.html