Skip to content

Commit

Permalink
Escape percent sign in link URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed Aug 27, 2023
1 parent 3984157 commit 230edb6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/LinkRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function render(Node $node, ChildNodeRendererInterface $childRenderer)
$replacements = [
'_' => '\\_',
'#' => '\#',
'%' => '\%',
];
$url = \str_replace(\array_keys($replacements), $replacements, $node->getUrl());

Expand Down
2 changes: 1 addition & 1 deletion tests/data/links.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Link with protocol and fragment: [label](https://example.org/lorem#ipsum).

Relative link: [label](./example.html).
Relative link: [label](./spaced%20example.html).

Inline URL with angle brackets: <https://example.org>

Expand Down
2 changes: 1 addition & 1 deletion tests/data/links.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Link with protocol and fragment: label\footnote{\url{https://example.org/lorem\#ipsum}}.

Relative link: label\footnote{\url{./example.html}}.
Relative link: label\footnote{\url{./spaced\%20example.html}}.

Inline URL with angle brackets: \url{https://example.org}

Expand Down

0 comments on commit 230edb6

Please sign in to comment.