Skip to content

Commit

Permalink
Merge pull request #1270 from nickgros/SWC-7113
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros authored Oct 14, 2024
2 parents e54a1f8 + 94826c1 commit 4676d84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/markdown-it-synapse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-it-synapse",
"version": "1.1.16",
"version": "1.1.17",
"description": "tag for markdown-it markdown parser.",
"main": "dist/index.cjs",
"module": "dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/markdown-it-synapse/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,11 @@ function init_markdown_it(
// if it has no href OR it is neither a synapse link or internal page link
if (hrefIndex < 0 || !(isInternalPageLink || isInternalSynapseLink)) {
tokens[idx].attrPush(['target', '_blank']) // add new attribute
tokens[idx].attrPush(['ref', 'noopener noreferrer']) // add new attribute
tokens[idx].attrPush(['rel', 'noopener noreferrer']) // add new attribute
}
} else {
tokens[idx].attrs[aIndex][1] = '_blank' // replace value of existing attr
tokens[idx].attrPush(['ref', 'noopener noreferrer']) // add ref
tokens[idx].attrPush(['rel', 'noopener noreferrer']) // add ref
}

// pass token to default renderer.
Expand Down
14 changes: 7 additions & 7 deletions packages/markdown-it-synapse/test/fixtures/synapse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,37 +67,37 @@ And here's another ${reference?inlineWidget=true&text=My %5Freference%5F with pr
.
What if I mention @jay in a comment?
.
<p>What if I mention <span data-widgetparams="badge?alias=jay" data-widget-type="badge" class="widgetContainer" id="widget-7undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=jay" target="_blank" ref="noopener noreferrer">@jay</a></span> in a comment?</p>
<p>What if I mention <span data-widgetparams="badge?alias=jay" data-widget-type="badge" class="widgetContainer" id="widget-7undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=jay" target="_blank" rel="noopener noreferrer">@jay</a></span> in a comment?</p>
.

.
@Beginning of line mention
.
<p><span data-widgetparams="badge?alias=Beginning" data-widget-type="badge" class="widgetContainer" id="widget-8undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=Beginning" target="_blank" ref="noopener noreferrer">@Beginning</a></span> of line mention</p>
<p><span data-widgetparams="badge?alias=Beginning" data-widget-type="badge" class="widgetContainer" id="widget-8undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=Beginning" target="_blank" rel="noopener noreferrer">@Beginning</a></span> of line mention</p>
.

.
Mention at the @end
.
<p>Mention at the <span data-widgetparams="badge?alias=end" data-widget-type="badge" class="widgetContainer" id="widget-9undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=end" target="_blank" ref="noopener noreferrer">@end</a></span></p>
<p>Mention at the <span data-widgetparams="badge?alias=end" data-widget-type="badge" class="widgetContainer" id="widget-9undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=end" target="_blank" rel="noopener noreferrer">@end</a></span></p>
.

.
Mention @xschildw, @withSupportedSpecialCharacters-._, @test! Expectation that it will not eat the comma or exclamation point.
.
<p>Mention <span data-widgetparams="badge?alias=xschildw" data-widget-type="badge" class="widgetContainer" id="widget-10undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=xschildw" target="_blank" ref="noopener noreferrer">@xschildw</a></span>, <span data-widgetparams="badge?alias=withSupportedSpecialCharacters-._" data-widget-type="badge" class="widgetContainer" id="widget-11undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=withSupportedSpecialCharacters-._" target="_blank" ref="noopener noreferrer">@withSupportedSpecialCharacters-._</a></span>, <span data-widgetparams="badge?alias=test" data-widget-type="badge" class="widgetContainer" id="widget-12undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=test" target="_blank" ref="noopener noreferrer">@test</a></span>! Expectation that it will not eat the comma or exclamation point.</p>
<p>Mention <span data-widgetparams="badge?alias=xschildw" data-widget-type="badge" class="widgetContainer" id="widget-10undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=xschildw" target="_blank" rel="noopener noreferrer">@xschildw</a></span>, <span data-widgetparams="badge?alias=withSupportedSpecialCharacters-._" data-widget-type="badge" class="widgetContainer" id="widget-11undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=withSupportedSpecialCharacters-._" target="_blank" rel="noopener noreferrer">@withSupportedSpecialCharacters-._</a></span>, <span data-widgetparams="badge?alias=test" data-widget-type="badge" class="widgetContainer" id="widget-12undefined"><a href="https://www.synapse.org/Portal/aliasredirector?alias=test" target="_blank" rel="noopener noreferrer">@test</a></span>! Expectation that it will not eat the comma or exclamation point.</p>
.

.
An email@address.com is not a mention
.
<p>An <a href="mailto:email@address.com" target="_blank" ref="noopener noreferrer">email@address.com</a> is not a mention</p>
<p>An <a href="mailto:email@address.com" target="_blank" rel="noopener noreferrer">email@address.com</a> is not a mention</p>
.

.
testing standard [link](http://link.com)
.
<p>testing standard <a href="http://link.com" target="_blank" ref="noopener noreferrer">link</a></p>
<p>testing standard <a href="http://link.com" target="_blank" rel="noopener noreferrer">link</a></p>
.

.
Expand All @@ -109,7 +109,7 @@ testing standard linkify syn123 auto-link
.
testing standard https://www.google.com auto-link
.
<p>testing standard <a href="https://www.google.com" target="_blank" ref="noopener noreferrer">https://www.google.com</a> auto-link</p>
<p>testing standard <a href="https://www.google.com" target="_blank" rel="noopener noreferrer">https://www.google.com</a> auto-link</p>
.

.
Expand Down

0 comments on commit 4676d84

Please sign in to comment.