Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
Add a converter that does not check output for rst errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Lane committed Oct 18, 2017
1 parent 03b6073 commit 765b2df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ a code block in HTML like `see <code>ref</code>_`, which is not expected.
* Sphinx extension
* add markdown support for sphinx
* ``mdinclude`` directive to include markdown from md or rst files
* option to parse relative links into ref and doc directives (``parse_relative_links``)
* option to parse relative links into ref and doc directives (``m2r_parse_relative_links``)
* Pure python implementation
* pandoc is not required

Expand Down
6 changes: 3 additions & 3 deletions m2r.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def parse(self, inputstring, document):
config = document.settings.env.config
converter = M2R(
no_underscore_emphasis=config.no_underscore_emphasis,
parse_relative_links=config.parse_relative_links
parse_relative_links=config.m2r_parse_relative_links
)
super(M2RParser, self).parse(converter(inputstring), document)

Expand Down Expand Up @@ -581,7 +581,7 @@ def run(self):
config = self.state.document.settings.env.config
converter = M2R(
no_underscore_emphasis=config.no_underscore_emphasis,
parse_relative_links=config.parse_relative_links
parse_relative_links=config.m2r_parse_relative_links
)
include_lines = statemachine.string2lines(converter(rawtext),
tab_width,
Expand All @@ -595,7 +595,7 @@ def setup(app):
global _is_sphinx
_is_sphinx = True
app.add_config_value('no_underscore_emphasis', False, 'env')
app.add_config_value('parse_relative_links', False, 'env')
app.add_config_value('m2r_parse_relative_links', False, 'env')
app.add_source_parser('.md', M2RParser)
app.add_directive('mdinclude', MdInclude)
metadata = dict(
Expand Down
13 changes: 7 additions & 6 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ def conv(self, src, **kwargs):
self.check_rst(out)
return out

def conv_no_check(self, src, **kwargs):
out = convert(src, **kwargs)
return out

def check_rst(self, rst):
pub = Publisher(reader=None, parser=None, writer=None, settings=None,
source_class=io.StringInput,
Expand Down Expand Up @@ -140,29 +144,26 @@ def test_link(self):

def test_anchor(self):
src = 'this is an [anchor](#anchor).'
out = self.conv(
out = self.conv_no_check(
src,
no_underscore_emphasis=True,
parse_relative_links=True
)
self.assertEqual(
out, '\nthis is an :ref:`anchor <anchor>`.\n')

def test_relative_link(self):
src = 'this is a [relative link](a_file.md).'
out = self.conv(
out = self.conv_no_check(
src,
no_underscore_emphasis=True,
parse_relative_links=True
)
self.assertEqual(
out, '\nthis is a :doc:`relative link <a_file>`.\n')

def test_relative_link_with_anchor(self):
src = 'this is a [relative link](a_file.md#anchor).'
out = self.conv(
out = self.conv_no_check(
src,
no_underscore_emphasis=True,
parse_relative_links=True
)
self.assertEqual(
Expand Down

0 comments on commit 765b2df

Please sign in to comment.