diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-09-23 22:54:34 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-09-23 22:54:34 -0300 |
commit | 9559a6febce8f1b2b5efb2c6d4ebf29484dce141 (patch) | |
tree | 14cf148e4f79b4528259474388e2f1fc5dcf94b0 /src/content/dependencies | |
parent | 15bc0f97e630a1b1d13d0bd80096d81b9a65d7de (diff) |
content: transformContent: override Tokenizer.url, ignore emails
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/transformContent.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/content/dependencies/transformContent.js b/src/content/dependencies/transformContent.js index 5f803a3b..4a0a4985 100644 --- a/src/content/dependencies/transformContent.js +++ b/src/content/dependencies/transformContent.js @@ -6,6 +6,21 @@ import {Marked} from 'marked'; const commonMarkedOptions = { headerIds: false, mangle: false, + + tokenizer: { + url(src) { + // Don't link emails + const cap = this.rules.inline.url.exec(src); + if (cap?.[2] === '@') return; + + // Use normal tokenizer url behavior otherwise + // Note that super.url doesn't work here because marked is binding or + // applying this function on the tokenizer instance - super.prop would + // just read the prototype of the containing object literal, not the + // rebound tokenizer. (Thanks MDN.) + return Object.getPrototypeOf(this).url.call(this, src); + }, + }, }; const multilineMarked = new Marked({ |