export { REGEXP_EMPTY_BLOCKQUOTE, REGEXP_EMPTY_OL, REGEXP_EMPTY_UL } from './cleanup.js'; /** * Matches ATX Markdown headers (1–6 `#` at start of string or after a newline). * * Flags: `gm`. Reset `.lastIndex` between `.test()` / `.exec()` calls. * * Captures: [1] start or newline, [2] the `#` run, [3] heading text. * * Fails on setext headers (`Title` / `=====`). * * @example * '# Header 1'.match(REGEXP_HEADER) * // ['# Header 1', '', '#', 'Header 1'] * @example Does not match setext `Title\n=====` */ declare const REGEXP_HEADER: RegExp; /** * Matches level-2 ATX headers only (`## …`). * * Flags: `gim`. Captures: [1] heading text. * * @example * '## Heading 2'.match(REGEXP_H2) * // ['## Heading 2', 'Heading 2'] * @example Does not match `# Heading 1` */ declare const REGEXP_H2: RegExp; /** * Matches level-3 ATX headers only (`### …`). * * Flags: `gim`. Captures: [1] heading text. * * @example * '### Heading 3'.match(REGEXP_H3) * // ['### Heading 3', 'Heading 3'] * @example Does not match `## Heading 2` */ declare const REGEXP_H3: RegExp; /** * Matches Markdown image syntax `![alt](url)`. Empty alt is valid. * * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls. * * Captures: [1] alt text, [2] url. * * Fails on reference images and on links without `!`. * * @example * '![logo](./logo.png)'.match(REGEXP_IMAGE) * // ['![logo](./logo.png)', 'logo', './logo.png'] * @example Does not match `[logo](./logo.png)` */ declare const REGEXP_IMAGE: RegExp; /** * Matches inline Markdown link syntax `[text](url)`. * * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls, * or use `matchAll`. * * Captures: [1] text, [2] url. * * Fails on reference links (`[text][id]`), links inside code unless you * use `extractLinks()`, and image syntax (use `REGEXP_IMAGE`). * * @example * '[a](b)'.match(REGEXP_LINK) * // ['[a](b)', 'a', 'b'] * @example Does not match `[GitHub][id]` */ declare const REGEXP_LINK: RegExp; /** * Matches bold/strong using `**` or `__`. * * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls. * * Captures: [1] text inside `**`, [2] text inside `__` (the other is undefined). * * Fails on nested `***bold italic***` and on single-star italic. * * @example * '**bold**'.match(REGEXP_STRONG) * // ['**bold**', 'bold', undefined] * @example Does not match `*italic*` */ declare const REGEXP_STRONG: RegExp; /** * Matches italic/emphasis using `*` or `_` with surrounding whitespace * (or start/end / `>` / `<`). * * Flags: `g`. Reset `.lastIndex` between `.test()` / `.exec()` calls. * * Captures: [1] leading context, [2] delimiter, [3] inner text, [4] trailing context. * * Fails on mid-word `foo_bar_baz`, nested `***bold italic***`, and * `not*italic*` with no surrounding whitespace. * * @example * ' *italic* '.match(REGEXP_ITALIC) * // [' *italic* ', ' ', '*', 'italic', ' '] * @example Does not match `not*italic*` */ declare const REGEXP_ITALIC: RegExp; /** * Matches strikethrough using `~~` delimiters. * * @example Matches `~~deleted~~` * @example Does not match `~deleted~` */ declare const REGEXP_DEL: RegExp; /** * Matches inline code using single backticks. Legacy alias of REGEXP_INLINE_CODE style matching. * * @example Matches `` `code` `` * @example Does not match a fenced ``` block */ declare const REGEXP_CODE: RegExp; /** * Matches the custom newsletter quote syntax `:"…"`. * * @example Matches `:"quoted text":` * @example Does not match `"quoted text"` */ declare const REGEXP_Q: RegExp; /** * Matches a blockquote line starting with `>` or `>` after a newline. * * @example Matches `\n> quoted paragraph` * @example Does not match `> quote` at the very start of the string */ declare const REGEXP_BLOCKQUOTE: RegExp; /** * Matches a horizontal rule: 5 or more dashes after a newline. * * @example Matches `\n-----` * @example Does not match `---` */ declare const REGEXP_HR: RegExp; /** * Heuristic: paragraph-like content sitting between two newlines. * * @example Matches `\nhello world\n` * @example Does not match a single-line string with no surrounding newlines */ declare const REGEXP_PARAGRAPH: RegExp; /** * Matches two or more consecutive newlines (`\n`, `\r\n`, or `\r`). * * @example Matches `a\n\nb` * @example Does not match a single `\n` */ declare const REGEXP_BR: RegExp; /** * Matches fenced code blocks using ``` or ~~~ fences. * Captures: [1] fence chars, [2] language, [3] body. * * @example Matches a fenced ```js block * @example Does not match indented-only code with no fence */ declare const REGEXP_FENCED_CODE: RegExp; /** * Matches inline code spans with balanced backticks. Prefer this over REGEXP_CODE. * * @example Matches `` `code` `` * @example Does not match escaped backticks */ declare const REGEXP_INLINE_CODE: RegExp; /** * Matches raw HTML tags including closing and self-closing forms. * * @example Matches `
`, ``, `
` * @example Does not match `<>` */ declare const REGEXP_HTML: RegExp; /** * Structured extraction result from {@link extract}. */ interface ExtractResult { headers: { level: number; text: string; }[]; links: { text: string; url: string; }[]; images: { alt: string; url: string; }[]; bold: string[]; italic: string[]; strikethrough: string[]; blockquotes: string[]; horizontalRules: string[]; unorderedLists: string[]; orderedLists: string[]; codeBlocks: { language: string; code: string; }[]; inlineCode: string[]; html: string[]; } /** * Extracts structured data from a Markdown string. * Fenced code is pulled out first, then inline code, so links and emphasis * inside code fences are not reported. * * REGEXP_HEADER groups used here: [2] `#` run, [3] text. * * @example extract('# Title\n\n[GitHub](https://github.com)') * @example Does not treat `[link](url)` inside a fenced block as a link */ declare function extract(markdown: string): ExtractResult; /** * Pulls inline links out of Markdown as `{ text, url }` objects. * Strips fenced and inline code first so `[a](b)` inside a fence is ignored. * * @example * extractLinks('[a](b)') * // [{ text: 'a', url: 'b' }] */ declare function extractLinks(markdown: string): { text: string; url: string; }[]; /** * Pulls images out of Markdown as `{ alt, url }` objects. * * @example * extractImages('![logo](./logo.png)') * // [{ alt: 'logo', url: './logo.png' }] */ declare function extractImages(markdown: string): { alt: string; url: string; }[]; /** * Pulls ATX headers as `{ level, text }`. * REGEXP_HEADER groups: [1] prefix, [2] `#` run, [3] text. * * @example * extractHeaders('# Title') * // [{ level: 1, text: 'Title' }] */ declare function extractHeaders(markdown: string): { level: number; text: string; }[]; /** * Matches an unordered `*` list item at start of string or after a newline. * Optional 4-space indent is allowed. Does not match `-` or `+` markers. * * @example Matches `* item one` * @example Does not match `- item one` */ declare const REGEXP_UL_LIST: RegExp; /** * Matches an ordered list item (`1. …`) at start of string or after a newline. * * @example Matches `1. first item` * @example Does not match `1) first item` */ declare const REGEXP_OL_LIST: RegExp; export { type ExtractResult, REGEXP_BLOCKQUOTE, REGEXP_BR, REGEXP_CODE, REGEXP_DEL, REGEXP_FENCED_CODE, REGEXP_H2, REGEXP_H3, REGEXP_HEADER, REGEXP_HR, REGEXP_HTML, REGEXP_IMAGE, REGEXP_INLINE_CODE, REGEXP_ITALIC, REGEXP_LINK, REGEXP_OL_LIST, REGEXP_PARAGRAPH, REGEXP_Q, REGEXP_STRONG, REGEXP_UL_LIST, extract, extractHeaders, extractImages, extractLinks };