Skip to content

Commit

Permalink
Merge branch 'release/0.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackMorganNZ committed Jan 14, 2018
2 parents c7fc5ae + afcf20c commit c434800
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 15 deletions.
10 changes: 10 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
#######################################

0.7.2
=======================================

- Fix bug where :doc:`processors/panel` processor does not handle punctuation 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
=======================================

Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 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
setuptools==38.4.0

# Required dependencies for building documentation
sphinx==1.6.5
sphinx==1.6.6
sphinx_rtd_theme==0.2.4
2 changes: 1 addition & 1 deletion verto/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa
from .Verto import Verto

__version__ = '0.7.1'
__version__ = '0.7.2'
8 changes: 4 additions & 4 deletions verto/processors/PanelBlockProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ def custom_parsing(self, content_blocks, argument_values):
blocks = []

argument = 'title'
title_r = re.compile(r'(^|\n)# ((\w| )*)(?P<args>)')
title_r = re.compile(r'^#(?!#+)\s?(?P<title>.*?)$')
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)
Expand Down
39 changes: 37 additions & 2 deletions verto/tests/HeadingTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'''
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
35 changes: 31 additions & 4 deletions verto/tests/PanelTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_punctuation(self):
'''Tests that a heading is parsed correctly
'''
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_punctuation_expected.html', strip=True)
self.assertEqual(expected_string, converted_test_string)

def test_heading_subtitle_false(self):
'''Tests that a heading is parsed correctly
'''
Expand Down Expand Up @@ -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_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_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_punctuation_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
'''
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions verto/tests/assets/heading/no_whitespace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#This is an H1

##This is an H2

######This is an H6
18 changes: 18 additions & 0 deletions verto/tests/assets/heading/no_whitespace_expected.html
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

##Subtitle

This panel does have a subtitle...but both headings are incorrect
Panel text.

{panel end}
Original file line number Diff line number Diff line change
@@ -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>
7 changes: 7 additions & 0 deletions verto/tests/assets/panel/heading_with_punctuation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{panel type="note"}

# crwdns8254:0crwdne8254:0

crwdns8255:0crwdne8255:0 crwdns8256:0crwdne8256:0 crwdns8257:0crwdne8257:0 crwdns8258:0crwdne8258:0

{panel end}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{panel type="note" subtitle="true"}

# Heading

## crwdns8299:0crwdne8299:0

This panel does have a subtitle!

{panel end}
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit c434800

Please sign in to comment.