Skip to content

Commit

Permalink
feat(ledge-render): open all links in new windows
Browse files Browse the repository at this point in the history
  • Loading branch information
giscafer authored and phodal committed Apr 23, 2020
1 parent be2e016 commit a5bf51e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
import marked from 'marked/lib/marked';

const renderer = new marked.Renderer();
renderer.link = (href, title, text) => {
const link = marked.Renderer.prototype.link.call(renderer, href, title, text);
if (/^https:\/\//.test(href) || /^http:\/\//.test(href)) {
return link.replace('<a', '<a target="_blank"');
}
return link;
};

marked.setOptions({
renderer,
});

const LedgeMarkdownConverter = {
// marked
escapeTest: /[&<>"']/,
Expand Down

0 comments on commit a5bf51e

Please sign in to comment.