Skip to content
111 changes: 0 additions & 111 deletions src/index.d.ts

This file was deleted.

27 changes: 0 additions & 27 deletions src/index.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* markdown-regex
*
* A set of ready-to-use RegExp constants for parsing and extracting
* elements from Markdown content.
*
* Ready-to-use RegExp constants for parsing Markdown.
* Zero runtime dependencies. Works in Node, browsers, and bundlers.
*
* @packageDocumentation
*/

export {
Expand Down
23 changes: 0 additions & 23 deletions src/list.js

This file was deleted.

7 changes: 4 additions & 3 deletions src/lists/empty-ol.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Matches consecutive ordered list HTML tags with optional whitespace.
* Useful for cleaning up generated HTML.
* Matches consecutive empty ordered-list HTML tags.
* Useful when cleaning generated HTML.
*
* Example: </ol><ol> or </ol> <ol>
* @example </ol><ol>
* @example </ol> <ol>
*/
export const REGEXP_EMPTY_OL = /<\/ol>\s?<ol>/g;
7 changes: 4 additions & 3 deletions src/lists/empty-ul.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Matches consecutive unordered list HTML tags with optional whitespace.
* Useful for cleaning up generated HTML.
* Matches consecutive empty unordered-list HTML tags.
* Useful when cleaning generated HTML.
*
* Example: </ul><ul> or </ul> <ul>
* @example </ul><ul>
* @example </ul> <ul>
*/
export const REGEXP_EMPTY_UL = /<\/ul>\s?<ul>/g;
10 changes: 6 additions & 4 deletions src/lists/ol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { NEWLINE } from '../utils';

/** Matches ordered list items: 1. item */
export const REGEXP_OL_LIST = new RegExp(NEWLINE + '[0-9]+\\.(.*)', 'g');
/**
* Matches an ordered list item (number + period after a newline).
*
* @example 1. first item
*/
export const REGEXP_OL_LIST = /(?:\r\n|\r|\n)\d+\.(.*)/g;
18 changes: 6 additions & 12 deletions src/lists/ul.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import { NEWLINE } from '../utils';

/**
* Matches unordered list items (lines starting with *).
* Supports optional leading indentation (4 spaces).
* Platform-agnostic newline handling.
* Matches an unordered list item (`*` after a newline).
* Optional 4-space indent is allowed.
*
* Example:
* * item one
* * item two
* @example
* * item one
* * item two
*/
export const REGEXP_UL_LIST = new RegExp(
`${NEWLINE}(((?:\\s{4})?\\*(.*?)${NEWLINE}){1,})`,
'g'
);
export const REGEXP_UL_LIST = /(?:\r\n|\r|\n)(?:\s{4})?\*(.*)/g;
54 changes: 0 additions & 54 deletions src/tags.js

This file was deleted.

10 changes: 4 additions & 6 deletions src/tags/blockquote.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { NEWLINE } from '../utils';

/**
* Matches blockquote lines starting with > or &gt;.
* Platform-agnostic newline handling.
* Matches blockquote lines starting with `>` or `&gt;` after a newline.
*
* Example: > blockquote text
* @example
* > quoted paragraph
*/
export const REGEXP_BLOCKQUOTE = new RegExp(`${NEWLINE}(&gt;|>)(.*)`, 'g');
export const REGEXP_BLOCKQUOTE = /(?:\r\n|\r|\n)(?:>|&gt;)(.*)/g;
8 changes: 4 additions & 4 deletions src/tags/br.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NEWLINE } from '../utils';

/**
* Matches two or more consecutive newlines (paragraph / line breaks).
* Platform-agnostic.
* Understands `\n`, `\r\n` and `\r`.
*
* @example a\\n\\nb
*/
export const REGEXP_BR = new RegExp(`((${NEWLINE}){2,})`, 'g');
export const REGEXP_BR = /(?:\r\n|\r|\n){2,}/g;
4 changes: 2 additions & 2 deletions src/tags/code.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Matches inline code using single backtick delimiters.
*
* Example: `code`
* @example `code`
*/
export const REGEXP_CODE = /`(.*?)`/g;
export const REGEXP_CODE = /`(.+?)`/g;
6 changes: 3 additions & 3 deletions src/tags/del.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Matches strikethrough text using ~~ delimiters.
* Matches strikethrough text using `~~` delimiters.
*
* Example: ~~strikethrough~~
* @example ~~deleted~~
*/
export const REGEXP_DEL = /~~(.*?)~~/g;
export const REGEXP_DEL = /~~(.+?)~~/g;
4 changes: 0 additions & 4 deletions src/tags/em.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/tags/em.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/tags/empty-blockquote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Matches consecutive empty blockquote HTML tags.
* Useful for cleaning up generated HTML.
* Useful when cleaning generated HTML.
*
* Example: </blockquote><blockquote>
* @example </blockquote><blockquote>
*/
export const REGEXP_EMPTY_BLOCKQUOTE = /<\/blockquote><blockquote>/g;
22 changes: 21 additions & 1 deletion src/tags/header.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
/** ATX headers after start-of-string or a newline. */
/**
* Matches ATX markdown headers (lines starting with 1–6 `#` characters).
* Matches at the start of the string or after a newline (Unix / Windows / old Mac).
*
* Captures: [1] the newline or start, [2] the `#` run, [3] the heading text.
*
* @example
* # Heading 1
* ## Heading 2
* ### Heading 3
*/
export const REGEXP_HEADER = /(^|\r\n|\r|\n)(#{1,6})\s+(.*)/gm;

/**
* Matches level-2 headers only (`## …`).
*
* @example ## Heading 2
*/
export const REGEXP_H2 = /^##\s+(.*)$/gim;

/**
* Matches level-3 headers only (`### …`).
*
* @example ### Heading 3
*/
export const REGEXP_H3 = /^###\s+(.*)$/gim;
9 changes: 3 additions & 6 deletions src/tags/hr.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { NEWLINE } from '../utils';

/**
* Matches horizontal rule lines (5 or more dashes).
* Platform-agnostic newline handling.
* Matches a horizontal rule: 5 or more dashes on their own line.
*
* Example: -----
* @example -----\n
*/
export const REGEXP_HR = new RegExp(`${NEWLINE}-{5,}`, 'g');
export const REGEXP_HR = /(?:\r\n|\r|\n)-{5,}/g;
Loading