diff options
| author | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
|---|---|---|
| committer | altaf-creator <dev@altafcreator.com> | 2026-04-30 22:01:53 +0800 |
| commit | db1c6676a13798ee57dbac429a1d5045b60356fb (patch) | |
| tree | 5ff305c09686de50bbcac404c1954e42c26ba494 /packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs | |
| parent | 97fa8f57fbefcbfa6b3e56c31a1e5b60ef1a9e37 (diff) | |
quite a big commit
Diffstat (limited to 'packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs')
| -rw-r--r-- | packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs b/packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs deleted file mode 100644 index fdc817a..0000000 --- a/packages/markdown-it-14.1.0/lib/rules_inline/linkify.mjs +++ /dev/null @@ -1,56 +0,0 @@ -// Process links like https://example.org/ - -// RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) -const SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i - -export default function linkify (state, silent) { - if (!state.md.options.linkify) return false - if (state.linkLevel > 0) return false - - const pos = state.pos - const max = state.posMax - - if (pos + 3 > max) return false - if (state.src.charCodeAt(pos) !== 0x3A/* : */) return false - if (state.src.charCodeAt(pos + 1) !== 0x2F/* / */) return false - if (state.src.charCodeAt(pos + 2) !== 0x2F/* / */) return false - - const match = state.pending.match(SCHEME_RE) - if (!match) return false - - const proto = match[1] - - const link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length)) - if (!link) return false - - let url = link.url - - // invalid link, but still detected by linkify somehow; - // need to check to prevent infinite loop below - if (url.length <= proto.length) return false - - // disallow '*' at the end of the link (conflicts with emphasis) - url = url.replace(/\*+$/, '') - - const fullUrl = state.md.normalizeLink(url) - if (!state.md.validateLink(fullUrl)) return false - - if (!silent) { - state.pending = state.pending.slice(0, -proto.length) - - const token_o = state.push('link_open', 'a', 1) - token_o.attrs = [['href', fullUrl]] - token_o.markup = 'linkify' - token_o.info = 'auto' - - const token_t = state.push('text', '', 0) - token_t.content = state.md.normalizeLinkText(url) - - const token_c = state.push('link_close', 'a', -1) - token_c.markup = 'linkify' - token_c.info = 'auto' - } - - state.pos += url.length - proto.length - return true -} |
