Skip to content

Commit c88ef26

Browse files
authored
Merge pull request #22 from livio/fix-paragrah-block
Fix paragrah block header issue
2 parents ac868c3 + a28a7de commit c88ef26

6 files changed

Lines changed: 37 additions & 6 deletions

File tree

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
History
33
=======
44

5+
0.2.6 (2019-06-12)
6+
------------------
7+
8+
* Fix block paragraph rendering with title
9+
510
0.2.5 (2019-06-12)
611
------------------
712

docdown/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """Jason Emerick"""
44
__email__ = 'jason@mobelux.com'
5-
__version__ = '0.2.5'
5+
__version__ = '0.2.6'

docdown/platform_section.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PlatformSectionPreprocessor(Preprocessor):
2020
PLATFORM_SECTION_RE = re.compile(r'''@!\[(?P<sections>[\w, ]+)\](?P<content>.*?)!@''', re.DOTALL | re.VERBOSE)
2121

2222
STARTSWITH_WHITESPACE_RE = re.compile(r'^\W+(@!\[|\n)')
23+
MULTI_NEWLINE_RE = re.compile(r'^(\n){2,}')
2324

2425
def __init__(self, platform_section, **kwargs):
2526
self.platform_section = platform_section.lower().strip()
@@ -42,7 +43,10 @@ def process_platform_sections(self, text):
4243
start = text[:m.start()]
4344
end = text[m.end():]
4445
if self.STARTSWITH_WHITESPACE_RE.match(end):
45-
end = end.lstrip()
46+
if self.MULTI_NEWLINE_RE.match(end):
47+
end = '\n' + end.lstrip()
48+
else:
49+
end = end.lstrip()
4650

4751
if self.platform_section in sections:
4852
content = m.group('content')

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.5
2+
current_version = 0.2.6
33
commit = True
44
tag = True
55

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name='docdown',
23-
version='0.2.5',
23+
version='0.2.6',
2424
description="DocDown is a Markdown extension for source code documentation.",
2525
long_description=readme + '\n\n' + history,
2626
author="Jason Emerick, Justin Michalicek",

tests/test_platform_section_extension.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def test_section_with_code_snippet(self):
160160
extensions=self.MARKDOWN_EXTENSIONS,
161161
output_format='html5'
162162
)
163-
expected_output = '<p>some Android content shown</p>\n<p><code>java\nString java = "asdf";</code>\n</p>'
163+
expected_output = '<p>some Android content shown</p>\n<p><code>java\nString java = "asdf";</code></p>'
164164
self.assertEqual(expected_output, html)
165165

166166
def test_multiple_sections_with_code_snippet(self):
@@ -181,7 +181,7 @@ def test_multiple_sections_with_code_snippet(self):
181181
extensions=self.MARKDOWN_EXTENSIONS,
182182
output_format='html5'
183183
)
184-
expected_output = '<p>some Android content shown</p>\n<p><code>java\nString java = "asdf";</code>\n</p>'
184+
expected_output = '<p>some Android content shown</p>\n<p><code>java\nString java = "asdf";</code></p>'
185185
self.assertEqual(expected_output, html)
186186

187187
def test_inline_platform_section(self):
@@ -307,3 +307,25 @@ def test_back_to_back_platform_section_tags(self):
307307
)
308308
expected_output = '<p>Back to back Android tags!</p>'
309309
self.assertEqual(expected_output, html)
310+
311+
def test_tag_end_paragraph_start_header(self):
312+
text = 'You need to implement this. @![ios]In iOS, also this.!@\n\n## Next Header\nThe header above should be rendered.\n'
313+
314+
html = markdown.markdown(
315+
text,
316+
extension_configs=self.build_config_for_platform_section('iOS'),
317+
extensions=['markdown.extensions.tables'] + self.MARKDOWN_EXTENSIONS,
318+
output_format='html5'
319+
)
320+
321+
expected_output = '<p>You need to implement this. In iOS, also this.</p>\n<h2>Next Header</h2>\n<p>The header above should be rendered.</p>'
322+
self.assertEqual(expected_output, html)
323+
324+
html = markdown.markdown(
325+
text,
326+
extension_configs=self.build_config_for_platform_section('Android'),
327+
extensions=['markdown.extensions.tables'] + self.MARKDOWN_EXTENSIONS,
328+
output_format='html5'
329+
)
330+
expected_output = '<p>You need to implement this. </p>\n<h2>Next Header</h2>\n<p>The header above should be rendered.</p>'
331+
self.assertEqual(expected_output, html)

0 commit comments

Comments
 (0)