Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 FIX: linkify link rendering #499

Merged
merged 1 commit into from Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions myst_parser/docutils_renderer.py
Expand Up @@ -677,7 +677,7 @@ def render_link(self, token: SyntaxTreeNode) -> None:
or any scheme if `myst_url_schemes` is None.
- Otherwise, forward to `render_internal_link`
"""
if token.markup == "autolink":
if token.info == "auto": # handles both autolink and linkify
return self.render_autolink(token)

if self.md_config.all_links_external:
Expand Down Expand Up @@ -733,10 +733,12 @@ def render_internal_link(self, token: SyntaxTreeNode) -> None:
self.render_children(token)

def render_autolink(self, token: SyntaxTreeNode) -> None:
refuri = target = escapeHtml(token.attrGet("href") or "") # type: ignore[arg-type]
ref_node = nodes.reference(target, target, refuri=refuri)
refuri = escapeHtml(token.attrGet("href") or "") # type: ignore[arg-type]
ref_node = nodes.reference()
ref_node["refuri"] = refuri
self.add_line_and_source_path(ref_node, token)
self.current_node.append(ref_node)
with self.current_node_context(ref_node, append=True):
self.render_children(token)

def render_html_inline(self, token: SyntaxTreeNode) -> None:
self.render_html_block(token)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_renderers/fixtures/myst-config.txt
Expand Up @@ -24,3 +24,13 @@ title: "The title *nested syntax*"
<title>
Other header
.

[linkify] --myst-enable-extensions=linkify
.
www.example.com
.
<document source="<string>">
<paragraph>
<reference refuri="http://www.example.com">
www.example.com
.