{"version":3,"sources":["../src/index.ts","../src/tags/header.ts","../src/tags/image.ts","../src/tags/link.ts","../src/tags/strong.ts","../src/tags/italic.ts","../src/tags/del.ts","../src/tags/code.ts","../src/tags/quote.ts","../src/tags/blockquote.ts","../src/tags/hr.ts","../src/tags/paragraph.ts","../src/tags/br.ts","../src/tags/empty-blockquote.ts","../src/code/index.ts","../src/html/index.ts","../src/extract.ts","../src/extractors.ts","../src/lists/ul.ts","../src/lists/ol.ts","../src/lists/empty-ul.ts","../src/lists/empty-ol.ts"],"sourcesContent":["/**\n * markdown-regex\n *\n * Ready-to-use RegExp constants for parsing Markdown.\n * Every public regex is global (`g`). Reset `.lastIndex` between `.test()`\n * / `.exec()` calls, or use `String.prototype.matchAll`.\n *\n * Prefer {@link extract}, {@link extractLinks}, {@link extractImages},\n * or {@link extractHeaders} over composing regexes yourself.\n *\n * HTML cleanup constants live on `markdown-regex/cleanup`.\n *\n * @packageDocumentation\n */\n\nexport {\n  REGEXP_HEADER,\n  REGEXP_H2,\n  REGEXP_H3,\n  REGEXP_IMAGE,\n  REGEXP_LINK,\n  REGEXP_STRONG,\n  REGEXP_ITALIC,\n  REGEXP_DEL,\n  REGEXP_CODE,\n  REGEXP_Q,\n  REGEXP_BLOCKQUOTE,\n  REGEXP_HR,\n  REGEXP_PARAGRAPH,\n  REGEXP_BR,\n  REGEXP_EMPTY_BLOCKQUOTE,\n} from './tags/index';\n\nexport { REGEXP_FENCED_CODE } from './code';\nexport { REGEXP_INLINE_CODE } from './code';\nexport { REGEXP_HTML } from './html';\nexport { extract } from './extract';\nexport type { ExtractResult } from './extract';\nexport { extractLinks, extractImages, extractHeaders } from './extractors';\n\nexport {\n  REGEXP_UL_LIST,\n  REGEXP_OL_LIST,\n  REGEXP_EMPTY_UL,\n  REGEXP_EMPTY_OL,\n} from './lists/index';\n","/**\n * Matches ATX Markdown headers (1–6 `#` at start of string or after a newline).\n *\n * Flags: `gm`. Reset `.lastIndex` between `.test()` / `.exec()` calls.\n *\n * Captures: [1] start or newline, [2] the `#` run, [3] heading text.\n *\n * Fails on setext headers (`Title` / `=====`).\n *\n * @example\n *   '# Header 1'.match(REGEXP_HEADER)\n *   // ['# Header 1', '', '#', 'Header 1']\n * @example Does not match setext `Title\\n=====`\n */\nexport const REGEXP_HEADER = /(^|\\r\\n|\\r|\\n)(#{1,6})\\s+(.*)/gm;\n\n/**\n * Matches level-2 ATX headers only (`## …`).\n *\n * Flags: `gim`. Captures: [1] heading text.\n *\n * @example\n *   '## Heading 2'.match(REGEXP_H2)\n *   // ['## Heading 2', 'Heading 2']\n * @example Does not match `# Heading 1`\n */\nexport const REGEXP_H2 = /^##\\s+(.*)$/gim;\n\n/**\n * Matches level-3 ATX headers only (`### …`).\n *\n * Flags: `gim`. Captures: [1] heading text.\n *\n * @example\n *   '### Heading 3'.match(REGEXP_H3)\n *   // ['### Heading 3', 'Heading 3']\n * @example Does not match `## Heading 2`\n */\nexport const REGEXP_H3 = /^###\\s+(.*)$/gim;\n","/**\n * Matches Markdown image syntax `![alt](url)`. Empty alt is valid.\n *\n * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls.\n *\n * Captures: [1] alt text, [2] url.\n *\n * Fails on reference images and on links without `!`.\n *\n * @example\n *   '![logo](./logo.png)'.match(REGEXP_IMAGE)\n *   // ['![logo](./logo.png)', 'logo', './logo.png']\n * @example Does not match `[logo](./logo.png)`\n */\nexport const REGEXP_IMAGE = /!\\[([^\\[]*?)\\]\\(([^)]+?)\\)/g;\n","/**\n * Matches inline Markdown link syntax `[text](url)`.\n *\n * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls,\n * or use `matchAll`.\n *\n * Captures: [1] text, [2] url.\n *\n * Fails on reference links (`[text][id]`), links inside code unless you\n * use `extractLinks()`, and image syntax (use `REGEXP_IMAGE`).\n *\n * @example\n *   '[a](b)'.match(REGEXP_LINK)\n *   // ['[a](b)', 'a', 'b']\n * @example Does not match `[GitHub][id]`\n */\nexport const REGEXP_LINK = /\\[([^\\[]*?)\\]\\(([^)]+?)\\)/g;\n","/**\n * Matches bold/strong using `**` or `__`.\n *\n * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls.\n *\n * Captures: [1] text inside `**`, [2] text inside `__` (the other is undefined).\n *\n * Fails on nested `***bold italic***` and on single-star italic.\n *\n * @example\n *   '**bold**'.match(REGEXP_STRONG)\n *   // ['**bold**', 'bold', undefined]\n * @example Does not match `*italic*`\n */\nexport const REGEXP_STRONG = /\\*\\*(.+?)\\*\\*|__(.+?)__/g;\n","/**\n * Matches italic/emphasis using `*` or `_` with surrounding whitespace\n * (or start/end / `>` / `<`).\n *\n * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls.\n *\n * Captures: [1] leading context, [2] delimiter, [3] inner text, [4] trailing context.\n *\n * Fails on mid-word `foo_bar_baz`, nested `***bold italic***`, and\n * `not*italic*` with no surrounding whitespace.\n *\n * @example\n *   ' *italic* '.match(REGEXP_ITALIC)\n *   // [' *italic* ', ' ', '*', 'italic', ' ']\n * @example Does not match `not*italic*`\n */\nexport const REGEXP_ITALIC = /(^|[\\s>])(\\*|_)(.+?)\\2([\\s<]|$)/g;\n","/**\n * Matches strikethrough using `~~` delimiters.\n *\n * @example Matches `~~deleted~~`\n * @example Does not match `~deleted~`\n */\nexport const REGEXP_DEL = /~~(.+?)~~/g;\n","/**\n * Matches inline code using single backticks. Legacy alias of REGEXP_INLINE_CODE style matching.\n *\n * @example Matches `` `code` ``\n * @example Does not match a fenced ``` block\n */\nexport const REGEXP_CODE = /`(.+?)`/g;\n","/**\n * Matches the custom newsletter quote syntax `:\"…\"`.\n *\n * @example Matches `:\"quoted text\":`\n * @example Does not match `\"quoted text\"`\n */\nexport const REGEXP_Q = /:\"(.*?)\":/g;\n","/**\n * Matches a blockquote line starting with `>` or `&gt;` after a newline.\n *\n * @example Matches `\\n> quoted paragraph`\n * @example Does not match `> quote` at the very start of the string\n */\nexport const REGEXP_BLOCKQUOTE = /(?:\\r\\n|\\r|\\n)(?:>|&gt;)(.*)/g;\n","/**\n * Matches a horizontal rule: 5 or more dashes after a newline.\n *\n * @example Matches `\\n-----`\n * @example Does not match `---`\n */\nexport const REGEXP_HR = /(?:\\r\\n|\\r|\\n)-{5,}/g;\n","/**\n * Heuristic: paragraph-like content sitting between two newlines.\n *\n * @example Matches `\\nhello world\\n`\n * @example Does not match a single-line string with no surrounding newlines\n */\nexport const REGEXP_PARAGRAPH = /(?:\\r\\n|\\r|\\n)(.+?)(?:\\r\\n|\\r|\\n)/g;\n","/**\n * Matches two or more consecutive newlines (`\\n`, `\\r\\n`, or `\\r`).\n *\n * @example Matches `a\\n\\nb`\n * @example Does not match a single `\\n`\n */\nexport const REGEXP_BR = /(?:\\r\\n|\\r|\\n){2,}/g;\n","/**\n * Matches consecutive empty blockquote HTML tags. Cleanup helper, not Markdown.\n *\n * @example Matches `</blockquote><blockquote>`\n * @example Does not match `<blockquote>quote</blockquote>`\n */\nexport const REGEXP_EMPTY_BLOCKQUOTE = /<\\/blockquote><blockquote>/g;\n","/**\n * Matches fenced code blocks using ``` or ~~~ fences.\n * Captures: [1] fence chars, [2] language, [3] body.\n *\n * @example Matches a fenced ```js block\n * @example Does not match indented-only code with no fence\n */\nexport const REGEXP_FENCED_CODE = /(?:^|\\n)(`{3,}|~{3,})([\\w-]*)\\r?\\n([\\s\\S]*?)\\r?\\n\\1(?=\\n|$)/g;\n\n/**\n * Matches inline code spans with balanced backticks. Prefer this over REGEXP_CODE.\n *\n * @example Matches `` `code` ``\n * @example Does not match escaped backticks\n */\nexport const REGEXP_INLINE_CODE = /(?<!\\\\)(`+)([^`\\n]+?)\\1(?!`)/g;\n","/**\n * Matches raw HTML tags including closing and self-closing forms.\n *\n * @example Matches `<div>`, `</span>`, `<br/>`\n * @example Does not match `<<not-a-tag>>`\n */\nexport const REGEXP_HTML = /<\\/?[a-z][\\w-]*(?:\\s+[\\w-]+(?:=(?:\"[^\"]*\"|'[^']*'|[^\\s>]+))?)*\\s*\\/?>/gi;\n","// src/extract.ts\nimport {\n  REGEXP_HEADER,\n  REGEXP_LINK,\n  REGEXP_IMAGE,\n  REGEXP_STRONG,\n  REGEXP_ITALIC,\n  REGEXP_DEL,\n  REGEXP_BLOCKQUOTE,\n  REGEXP_HR,\n  REGEXP_UL_LIST,\n  REGEXP_OL_LIST,\n  REGEXP_FENCED_CODE,\n  REGEXP_INLINE_CODE,\n  REGEXP_HTML,\n} from './index';\n\n/**\n * Structured extraction result from {@link extract}.\n */\nexport interface ExtractResult {\n  headers: { level: number; text: string }[];\n  links: { text: string; url: string }[];\n  images: { alt: string; url: string }[];\n  bold: string[];\n  italic: string[];\n  strikethrough: string[];\n  blockquotes: string[];\n  horizontalRules: string[];\n  unorderedLists: string[];\n  orderedLists: string[];\n  codeBlocks: { language: string; code: string }[];\n  inlineCode: string[];\n  html: string[];\n}\n\n/**\n * Extracts structured data from a Markdown string.\n * Fenced code is pulled out first, then inline code, so links and emphasis\n * inside code fences are not reported.\n *\n * REGEXP_HEADER groups used here: [2] `#` run, [3] text.\n *\n * @example extract('# Title\\n\\n[GitHub](https://github.com)')\n * @example Does not treat `[link](url)` inside a fenced block as a link\n */\nexport function extract(markdown: string): ExtractResult {\n  const result: ExtractResult = {\n    headers: [],\n    links: [],\n    images: [],\n    bold: [],\n    italic: [],\n    strikethrough: [],\n    blockquotes: [],\n    horizontalRules: [],\n    unorderedLists: [],\n    orderedLists: [],\n    codeBlocks: [],\n    inlineCode: [],\n    html: [],\n  };\n\n  let working = markdown;\n\n  const fencedMatches = [...working.matchAll(REGEXP_FENCED_CODE)];\n  for (const m of fencedMatches) {\n    result.codeBlocks.push({\n      language: m[2] || '',\n      code: m[3],\n    });\n  }\n  working = working.replace(REGEXP_FENCED_CODE, '\\n__CODE_BLOCK__\\n');\n\n  const inlineMatches = [...working.matchAll(REGEXP_INLINE_CODE)];\n  for (const m of inlineMatches) {\n    result.inlineCode.push(m[2]);\n  }\n  working = working.replace(REGEXP_INLINE_CODE, '__INLINE_CODE__');\n\n  for (const m of working.matchAll(REGEXP_HEADER)) {\n    result.headers.push({\n      level: m[2].length,\n      text: m[3].trim(),\n    });\n  }\n\n  for (const m of working.matchAll(REGEXP_LINK)) {\n    result.links.push({ text: m[1], url: m[2] });\n  }\n\n  for (const m of working.matchAll(REGEXP_IMAGE)) {\n    result.images.push({ alt: m[1], url: m[2] });\n  }\n\n  for (const m of working.matchAll(REGEXP_STRONG)) {\n    result.bold.push(m[1] ?? m[2]);\n  }\n\n  for (const m of working.matchAll(REGEXP_ITALIC)) {\n    result.italic.push(m[3]);\n  }\n\n  for (const m of working.matchAll(REGEXP_DEL)) {\n    result.strikethrough.push(m[1]);\n  }\n\n  for (const m of working.matchAll(REGEXP_BLOCKQUOTE)) {\n    result.blockquotes.push(m[1]);\n  }\n\n  for (const m of working.matchAll(REGEXP_HR)) {\n    result.horizontalRules.push(m[0]);\n  }\n\n  for (const m of working.matchAll(REGEXP_UL_LIST)) {\n    result.unorderedLists.push(m[1]);\n  }\n\n  for (const m of working.matchAll(REGEXP_OL_LIST)) {\n    result.orderedLists.push(m[1]);\n  }\n\n  for (const m of working.matchAll(REGEXP_HTML)) {\n    result.html.push(m[0]);\n  }\n\n  return result;\n}\n","import { REGEXP_HEADER, REGEXP_IMAGE, REGEXP_LINK } from './tags/index';\nimport { REGEXP_FENCED_CODE, REGEXP_INLINE_CODE } from './code';\n\nfunction withoutCode(markdown: string): string {\n  return markdown\n    .replace(REGEXP_FENCED_CODE, '\\n')\n    .replace(REGEXP_INLINE_CODE, ' ');\n}\n\n/**\n * Pulls inline links out of Markdown as `{ text, url }` objects.\n * Strips fenced and inline code first so `[a](b)` inside a fence is ignored.\n *\n * @example\n *   extractLinks('[a](b)')\n *   // [{ text: 'a', url: 'b' }]\n */\nexport function extractLinks(markdown: string): { text: string; url: string }[] {\n  const links: { text: string; url: string }[] = [];\n  for (const m of withoutCode(markdown).matchAll(REGEXP_LINK)) {\n    links.push({ text: m[1], url: m[2] });\n  }\n  return links;\n}\n\n/**\n * Pulls images out of Markdown as `{ alt, url }` objects.\n *\n * @example\n *   extractImages('![logo](./logo.png)')\n *   // [{ alt: 'logo', url: './logo.png' }]\n */\nexport function extractImages(markdown: string): { alt: string; url: string }[] {\n  const images: { alt: string; url: string }[] = [];\n  for (const m of withoutCode(markdown).matchAll(REGEXP_IMAGE)) {\n    images.push({ alt: m[1], url: m[2] });\n  }\n  return images;\n}\n\n/**\n * Pulls ATX headers as `{ level, text }`.\n * REGEXP_HEADER groups: [1] prefix, [2] `#` run, [3] text.\n *\n * @example\n *   extractHeaders('# Title')\n *   // [{ level: 1, text: 'Title' }]\n */\nexport function extractHeaders(markdown: string): { level: number; text: string }[] {\n  const headers: { level: number; text: string }[] = [];\n  for (const m of withoutCode(markdown).matchAll(REGEXP_HEADER)) {\n    headers.push({ level: m[2].length, text: m[3].trim() });\n  }\n  return headers;\n}\n","/**\n * Matches an unordered `*` list item at start of string or after a newline.\n * Optional 4-space indent is allowed. Does not match `-` or `+` markers.\n *\n * @example Matches `* item one`\n * @example Does not match `- item one`\n */\nexport const REGEXP_UL_LIST = /(?:^|\\r\\n|\\r|\\n)(?:\\s{4})?\\*(.*)/gm;\n","/**\n * Matches an ordered list item (`1. …`) at start of string or after a newline.\n *\n * @example Matches `1. first item`\n * @example Does not match `1) first item`\n */\nexport const REGEXP_OL_LIST = /(?:^|\\r\\n|\\r|\\n)\\d+\\.(.*)/gm;\n","/**\n * Matches consecutive empty unordered-list HTML tags. Cleanup helper, not Markdown.\n *\n * @example Matches `</ul><ul>` and `</ul> <ul>`\n * @example Does not match `<ul><li>item</li></ul>`\n */\nexport const REGEXP_EMPTY_UL = /<\\/ul>\\s?<ul>/g;\n","/**\n * Matches consecutive empty ordered-list HTML tags. Cleanup helper, not Markdown.\n *\n * @example Matches `</ol><ol>` and `</ol> <ol>`\n * @example Does not match `<ol><li>item</li></ol>`\n */\nexport const REGEXP_EMPTY_OL = /<\\/ol>\\s?<ol>/g;\n"],"m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