diff --git a/sphinx_mdinclude/render.py b/sphinx_mdinclude/render.py index cec40d6..bc0e5da 100644 --- a/sphinx_mdinclude/render.py +++ b/sphinx_mdinclude/render.py @@ -190,15 +190,7 @@ def text(self, text): """ return text - def autolink(self, link, is_email=False): - """Rendering a given link or email address. - - :param link: link content or email address. - :param is_email: whether this is an email or not. - """ - return link - - def link(self, link, text, title): + def link(self, link, text, title=None): """Rendering a given link with content and title. :param link: href link for ```` tag. diff --git a/sphinx_mdinclude/sphinx.py b/sphinx_mdinclude/sphinx.py index a4d8aea..44e0f87 100644 --- a/sphinx_mdinclude/sphinx.py +++ b/sphinx_mdinclude/sphinx.py @@ -8,6 +8,7 @@ from docutils import io, nodes, statemachine, utils from docutils.core import ErrorString from docutils.parsers import rst +from docutils.parsers.rst import directives as rst_directives from docutils.utils import SafeString from . import RestMarkdown @@ -59,7 +60,7 @@ def run(self): self.lineno - self.state_machine.input_offset - 1 ) source_dir = os.path.dirname(os.path.abspath(source)) - path = rst.directives.path(self.arguments[0]) + path = rst_directives.path(self.arguments[0]) path = os.path.normpath(os.path.join(source_dir, path)) path = utils.relative_path(None, path) path = nodes.reprunicode(path) diff --git a/sphinx_mdinclude/tests/test_renderer.py b/sphinx_mdinclude/tests/test_renderer.py index f48f118..63c6a66 100644 --- a/sphinx_mdinclude/tests/test_renderer.py +++ b/sphinx_mdinclude/tests/test_renderer.py @@ -132,7 +132,7 @@ def test_double_emphasis__(self): out = self.conv(src) self.assertEqual(out.replace("\n", ""), "**a**") - def test_autolink(self): + def test_not_an_autolink(self): src = "link to http://example.com/ in sentence." out = self.conv(src) self.assertEqual(out, "\n" + src + "\n") @@ -147,6 +147,11 @@ def test_anchor(self): out = self.conv_no_check(src) self.assertEqual(out, "\nthis is an :ref:`anchor link `.\n") + def test_autolink(self): + src = "link " + out = self.conv(src) + self.assertEqual(out, "\nlink `http://example.com `_\n") + def test_link_title(self): src = 'this is a [link](http://example.com/ "example").' out = self.conv(src)