{"version":3,"file":"entity.mjs","sources":["../../../../../../node_modules/markdown-it/lib/rules_inline/entity.mjs"],"sourcesContent":["// Process html entity - &#123;, &#xAF;, &quot;, ...\n\nimport { decodeHTML } from 'entities'\nimport { isValidEntityCode, fromCodePoint } from '../common/utils.mjs'\n\nconst DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i\nconst NAMED_RE   = /^&([a-z][a-z0-9]{1,31});/i\n\nexport default function entity (state, silent) {\n  const pos = state.pos\n  const max = state.posMax\n\n  if (state.src.charCodeAt(pos) !== 0x26/* & */) return false\n\n  if (pos + 1 >= max) return false\n\n  const ch = state.src.charCodeAt(pos + 1)\n\n  if (ch === 0x23 /* # */) {\n    const match = state.src.slice(pos).match(DIGITAL_RE)\n    if (match) {\n      if (!silent) {\n        const code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10)\n\n        const token   = state.push('text_special', '', 0)\n        token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD)\n        token.markup  = match[0]\n        token.info    = 'entity'\n      }\n      state.pos += match[0].length\n      return true\n    }\n  } else {\n    const match = state.src.slice(pos).match(NAMED_RE)\n    if (match) {\n      const decoded = decodeHTML(match[0])\n      if (decoded !== match[0]) {\n        if (!silent) {\n          const token   = state.push('text_special', '', 0)\n          token.content = decoded\n          token.markup  = match[0]\n          token.info    = 'entity'\n        }\n        state.pos += match[0].length\n        return true\n      }\n    }\n  }\n\n  return false\n}\n"],"names":["DIGITAL_RE","NAMED_RE","entity","state","silent","pos","max","match","code","token","isValidEntityCode","fromCodePoint","decoded","decodeHTML"],"mappings":";;AAKA,MAAMA,IAAa,wCACbC,IAAa;AAEJ,SAASC,EAAQC,GAAOC,GAAQ;AAC7C,QAAMC,IAAMF,EAAM,KACZG,IAAMH,EAAM;AAIlB,MAFIA,EAAM,IAAI,WAAWE,CAAG,MAAM,MAE9BA,IAAM,KAAKC,EAAK,QAAO;AAI3B,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