Skip to content

Commit 5ff9a4e

Browse files
authored
Merge pull request #301 from LLazyEmail/copilot/refactor-regex-file-structure
feat: modularize markdown-regex into per-feature source files with comprehensive test suite
2 parents d497dba + 2296428 commit 5ff9a4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2073
-2211
lines changed

package-lock.json

Lines changed: 0 additions & 696 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
1-
import {
1+
export {
22
REGEXP_HEADER,
3+
REGEXP_H2,
4+
REGEXP_H3,
35
REGEXP_IMAGE,
46
REGEXP_LINK,
57
REGEXP_STRONG,
68
REGEXP_DEL,
79
REGEXP_Q,
810
REGEXP_CODE,
9-
// -----------
1011
REGEXP_BLOCKQUOTE,
1112
REGEXP_HR,
1213
REGEXP_PARAGRAPH,
13-
// -----------
1414
REGEXP_BR,
1515
REGEXP_EMPTY_BLOCKQUOTE,
1616
REGEXP_EM,
17-
} from "./tags";
18-
import {
19-
REGEXP_UL_LIST,
20-
REGEXP_OL_LIST,
21-
REGEXP_EMPTY_UL,
22-
REGEXP_EMPTY_OL,
23-
} from "./list";
24-
17+
} from "./tags/index";
2518
export {
26-
REGEXP_HEADER,
27-
REGEXP_IMAGE,
28-
REGEXP_LINK,
29-
REGEXP_STRONG,
30-
REGEXP_DEL,
31-
REGEXP_Q,
32-
REGEXP_CODE,
3319
REGEXP_UL_LIST,
3420
REGEXP_OL_LIST,
35-
REGEXP_BLOCKQUOTE,
36-
REGEXP_HR,
37-
REGEXP_PARAGRAPH,
3821
REGEXP_EMPTY_UL,
3922
REGEXP_EMPTY_OL,
40-
REGEXP_BR,
41-
REGEXP_EMPTY_BLOCKQUOTE,
42-
REGEXP_EM,
43-
};
23+
} from "./lists/index";
4424

src/lists/empty-ol.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const REGEXP_EMPTY_OL = /<\/ol>\s?<ol>/g;
2+
3+
export { REGEXP_EMPTY_OL };

src/lists/empty-ul.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const REGEXP_EMPTY_UL = /<\/ul>\s?<ul>/g;
2+
3+
export { REGEXP_EMPTY_UL };

src/lists/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { REGEXP_UL_LIST } from "./ul";
2+
export { REGEXP_OL_LIST } from "./ol";
3+
export { REGEXP_EMPTY_UL } from "./empty-ul";
4+
export { REGEXP_EMPTY_OL } from "./empty-ol";

src/lists/ol.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os from "os";
2+
3+
const platform = os.platform();
4+
5+
const newLine = platform === "win32" ? "\r\n" : "\n";
6+
7+
const REGEXP_OL_LIST = new RegExp(`${newLine}[0-9]+\\.(.*)`, "g");
8+
9+
export { REGEXP_OL_LIST };

src/lists/ul.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os from "os";
2+
3+
const platform = os.platform();
4+
5+
const newLine = platform === "win32" ? "\r\n" : "\n";
6+
7+
const REGEXP_UL_LIST = new RegExp(
8+
`${newLine}(((\\s{4})?\\*(.*?)${newLine}){1,})`,
9+
"g"
10+
);
11+
12+
export { REGEXP_UL_LIST };

src/tags/blockquote.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os from "os";
2+
3+
const platform = os.platform();
4+
5+
const newLine = platform === "win32" ? "\r\n" : "\n";
6+
7+
const REGEXP_BLOCKQUOTE = new RegExp(`${newLine}(&gt;|\\>)(.*)`, "g");
8+
9+
export { REGEXP_BLOCKQUOTE };

src/tags/br.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import os from "os";
2+
3+
const platform = os.platform();
4+
5+
const newLine = platform === "win32" ? "\r\n" : "\n";
6+
7+
const REGEXP_BR = new RegExp(`((${newLine}){2,})`, "g");
8+
9+
export { REGEXP_BR };

src/tags/code.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const REGEXP_CODE = /`(.*?)`/g;
2+
3+
export { REGEXP_CODE };

0 commit comments

Comments
 (0)