1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-24 08:12:24 +02:00

Desktop: Fixes #8743: Fix escapes breaking linkified URLs (#8873)

This commit is contained in:
Henry Heino 2023-09-17 00:35:40 -07:00 committed by GitHub
parent fed623e3a4
commit 8324af5682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,6 @@
<ul>
<li><a href="http://example.com/a_test">http://example.com/a_test</a></li>
<li><a href="http://example.com/a_test/___">http://example.com/a_test/___</a></li>
<li>Another <i>test</i>: <a href="http://example.com/a_test/*">http://example.com/a_test/*</a></li>
<li>And another <b>test</b>: <a href="http://example.com/_test_">Test</a></li>
</ul>

View File

@ -0,0 +1,4 @@
- http://example.com/a_test
- http://example.com/a_test/___
- Another *test*: http://example.com/a_test/*
- And another **test**: [Test](http://example.com/_test_)

View File

@ -313,6 +313,12 @@ rules.inlineLink = {
)
},
escapeContent: function (node, _options) {
// Disable escaping content (including '_'s) when the link has the same URL and href.
// This prevents links from being broken by added escapes.
return node.getAttribute('href') !== node.textContent;
},
replacement: function (content, node, options) {
var href = filterLinkHref(node.getAttribute('href'))

View File

@ -216,7 +216,7 @@ function postProcess (output) {
function replacementForNode (node) {
var rule = this.rules.forNode(node)
var content = process.call(this, node, rule.escapeContent ? rule.escapeContent() : 'auto')
var content = process.call(this, node, rule.escapeContent ? rule.escapeContent(node) : 'auto')
var whitespace = node.flankingWhitespace
if (whitespace.leading || whitespace.trailing) content = content.trim()