Skip to content

Commit

Permalink
Merge pull request #20 from livio/inline_tables
Browse files Browse the repository at this point in the history
Fix whitespace issues with inline tables
  • Loading branch information
jemerick authored Jun 11, 2019
2 parents b7ec40e + 6ee83cf commit f3df9d4
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 7 deletions.
5 changes: 5 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
History
=======

0.2.4 (2019-06-11)
------------------

* Fix whitespace issues with inline platform tags breaking markdown table formatting

0.2.3 (2019-06-06)
------------------

Expand Down
2 changes: 1 addition & 1 deletion docdown/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Jason Emerick"""
__email__ = '[email protected]'
__version__ = '0.2.3'
__version__ = '0.2.4'
2 changes: 1 addition & 1 deletion docdown/platform_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def process_inline(self, text):
content = m.group('content')
text = '%s%s%s' % (text[:m.start()], content, text[m.end():])
else:
text = '%s%s' % (text[:m.start()], text[m.end():])
text = '%s%s' % (text[:m.start()], text[m.end():].lstrip())
else:
break
return text
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.3
current_version = 0.2.4
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='docdown',
version='0.2.3',
version='0.2.4',
description="DocDown is a Markdown extension for source code documentation.",
long_description=readme + '\n\n' + history,
author="Jason Emerick, Justin Michalicek",
Expand Down
79 changes: 76 additions & 3 deletions tests/test_platform_section_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_inline_platform_section(self):
extensions=self.MARKDOWN_EXTENSIONS,
output_format='html5'
)
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>AppServiceManifest</code> object.</p>'
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>AppServiceManifest</code> object.</p>'
self.assertEqual(expected_output, html)

html = markdown.markdown(
Expand All @@ -203,7 +203,7 @@ def test_inline_platform_section(self):
extensions=self.MARKDOWN_EXTENSIONS,
output_format='html5'
)
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>AppServiceManifest</code> object.</p>'
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>AppServiceManifest</code> object.</p>'
self.assertEqual(expected_output, html)

html = markdown.markdown(
Expand All @@ -212,5 +212,78 @@ def test_inline_platform_section(self):
extensions=self.MARKDOWN_EXTENSIONS,
output_format='html5'
)
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>SDLAppServiceManifest</code> object.</p>'
expected_output = '<h3>1. Creating an App Service Manifest</h3>\n<p>The first step to publishing is to create an <code>SDLAppServiceManifest</code> object.</p>'
self.assertEqual(expected_output, html)

text = 'This is just some inline text for the @![ios]iOS!@ @![android]Android!@ platform.'
html = markdown.markdown(
text,
extension_configs=self.build_config_for_platform_section('iOS'),
extensions=self.MARKDOWN_EXTENSIONS,
output_format='html5'
)
expected_output = '<p>This is just some inline text for the iOS platform.</p>'
self.assertEqual(expected_output, html)

html = markdown.markdown(
text,
extension_configs=self.build_config_for_platform_section('Android'),
extensions=self.MARKDOWN_EXTENSIONS,
output_format='html5'
)
expected_output = '<p>This is just some inline text for the Android platform.</p>'
print(html)
self.assertEqual(expected_output, html)

def test_table_row_platform_section(self):
text = ('### Header\n'
'| Parameters | Description | Notes |\n'
'| ------------- | ------------- |------------- |\n'
'| @![iOS]syncMsgVersion!@ @![Android]SYNC_MSG_VERSION!@ | Specifies the version number of the SDL V4 interface. | Check SDLSyncMsgVersion.h for more information |\n'
'| language | The currently active language on Sync. | Check SDLLanguage.h for more information |\n'
'| vehicleType | The make, model, year, and the trim of the vehicle. | Check SDLVehicleType.h for more information |\n'
'\n')

html = markdown.markdown(
text,
extension_configs=self.build_config_for_platform_section('Android'),
extensions=['markdown.extensions.tables'] + self.MARKDOWN_EXTENSIONS,
output_format='html5'
)

expected_output = ('<h3>Header</h3>\n<table>\n<thead>\n'
'<tr>\n<th>Parameters</th>\n<th>Description</th>\n<th>Notes</th>\n</tr>\n'
'</thead>\n<tbody>\n'
'<tr>\n<td>SYNC_MSG_VERSION</td>\n<td>Specifies the version number of the SDL V4 interface.</td>\n<td>Check SDLSyncMsgVersion.h for more information</td>\n</tr>\n'
'<tr>\n<td>language</td>\n<td>The currently active language on Sync.</td>\n<td>Check SDLLanguage.h for more information</td>\n</tr>\n'
'<tr>\n<td>vehicleType</td>\n<td>The make, model, year, and the trim of the vehicle.</td>\n<td>Check SDLVehicleType.h for more information</td>\n</tr>\n'
'</tbody>\n</table>'
)

self.assertEqual(expected_output, html)

text = ('### Header\n'
'| Parameters | Description | Notes |\n'
'| ------------- | ------------- |------------- |\n'
'| @![iOS]syncMsgVersion!@ @![Android]SYNC_MSG_VERSION!@ | Specifies the version number of the SDL V4 interface. | Check SDLSyncMsgVersion.h for more information |\n'
'@![iOS]| language | The currently active language on Sync. | Check SDLLanguage.h for more information |!@ \n'
'| vehicleType | The make, model, year, and the trim of the vehicle. | Check SDLVehicleType.h for more information |\n'
'\n')

html = markdown.markdown(
text,
extension_configs=self.build_config_for_platform_section('Android'),
extensions=['markdown.extensions.tables'] + self.MARKDOWN_EXTENSIONS,
output_format='html5'
)

expected_output = ('<h3>Header</h3>\n<table>\n<thead>\n'
'<tr>\n<th>Parameters</th>\n<th>Description</th>\n<th>Notes</th>\n</tr>\n'
'</thead>\n<tbody>\n'
'<tr>\n<td>SYNC_MSG_VERSION</td>\n<td>Specifies the version number of the SDL V4 interface.</td>\n<td>Check SDLSyncMsgVersion.h for more information</td>\n</tr>\n'
'<tr>\n<td>vehicleType</td>\n<td>The make, model, year, and the trim of the vehicle.</td>\n<td>Check SDLVehicleType.h for more information</td>\n</tr>\n'
'</tbody>\n</table>'
)

self.assertEqual(expected_output, html)
print(html)

0 comments on commit f3df9d4

Please sign in to comment.