File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
__tests__/utils/markdownit/__snapshots__ Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ exports[`renderEmailMarkdown should only process email markdown rules 1`] = `
1212<li >ordered list item 1</li >
1313<li >ordered list item 2</li >
1414</ol >
15- <p ><a href = " https://www.nhs.uk/example" >Read more</a ></p >
15+ <p ><a href = " https://www.nhs.uk/example" target = " _blank " rel = " noopener noreferrer " >Read more</a ></p >
1616<p >https://www.nhs.uk/example</p >
1717<p >Before page break</p >
1818<hr >
@@ -38,7 +38,7 @@ exports[`renderNHSAppMarkdown should only process nhs app markdown rules 1`] = `
3838<li >ordered list item 1</li >
3939<li >ordered list item 2</li >
4040</ol >
41- <p ><a href = " https://www.nhs.uk/example" >Read more</a ></p >
41+ <p ><a href = " https://www.nhs.uk/example" target = " _blank " rel = " noopener noreferrer " >Read more</a ></p >
4242<p >https://www.nhs.uk/example</p >
4343<p >Before page break
4444***
Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ import { lineBreak } from './plugins/line-break';
44export class MarkdownItWrapper extends MarkdownIt {
55 constructor ( ) {
66 super ( 'zero' ) ;
7+
8+ // rendered links should open in a new tab
9+ this . renderer . rules . link_open = ( tokens , idx ) => {
10+ const href = tokens [ idx ] . attrGet ( 'href' ) ;
11+
12+ return `<a href="${ href } " target="_blank" rel="noopener noreferrer">` ;
13+ } ;
714 }
815
916 /**
You can’t perform that action at this time.
0 commit comments