PHP 8.2.30
Preview: linkify.mjs Size: 1.86 KB
/home/byroehnu/.trash/node_modules11/markdown-it/lib/rules_inline/linkify.mjs

// 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)
  // do manual backsearch to avoid perf issues with regex /\*+$/ on "****...****a".
  let urlEnd = url.length
  while (urlEnd > 0 && url.charCodeAt(urlEnd - 1) === 0x2A/* * */) {
    urlEnd--
  }
  if (urlEnd !== url.length) {
    url = url.slice(0, urlEnd)
  }

  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
}

Directory Contents

Dirs: 0 × Files: 15

Name Size Perms Modified Actions
1.96 KB lrw-r--r-- 2026-02-28 00:28:22
Edit Download
1.63 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
3.99 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
3.44 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
1.45 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
1.39 KB lrw-r--r-- 2026-02-28 00:28:40
Edit Download
1.24 KB lrw-r--r-- 2026-02-28 00:28:44
Edit Download
1.14 KB lrw-r--r-- 2026-02-28 00:28:54
Edit Download
3.55 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
3.64 KB lrw-r--r-- 2026-02-28 00:29:04
Edit Download
1.86 KB lrw-r--r-- 2026-02-28 00:29:06
Edit Download
1.17 KB lrw-r--r-- 2026-02-28 00:29:08
Edit Download
3.41 KB lrw-r--r-- 2026-02-28 00:29:30
Edit Download
2.87 KB lrw-r--r-- 2026-02-28 00:29:32
Edit Download
2.05 KB lrw-r--r-- 2026-02-28 00:29:34
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).