Skip to content

Commit 99fb728

Browse files
committed
feat: add the ability to only parse specific markdown rules
1 parent e60eefd commit 99fb728

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/parseExpensiMark.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ const MAX_PARSABLE_LENGTH = 4000;
2828
type Token = ['TEXT' | 'HTML', string];
2929
type StackItem = {tag: string; children: Array<StackItem | string>};
3030

31-
function parseMarkdownToHTML(markdown: string): string {
31+
function parseMarkdownToHTML(markdown: string, filterRules: string[] | undefined): string {
3232
const parser = new ExpensiMark();
3333
const html = parser.replace(markdown, {
3434
shouldKeepRawInput: true,
35+
filterRules,
3536
});
3637
return html as string;
3738
}
@@ -240,11 +241,11 @@ function parseTreeToTextAndRanges(tree: StackItem): [string, MarkdownRange[]] {
240241

241242
const isNative = Platform.OS === 'android' || Platform.OS === 'ios';
242243

243-
function parseExpensiMark(markdown: string): MarkdownRange[] {
244+
function parseExpensiMark(markdown: string, filterRules?: string[]): MarkdownRange[] {
244245
if (markdown.length > MAX_PARSABLE_LENGTH) {
245246
return [];
246247
}
247-
const html = parseMarkdownToHTML(markdown);
248+
const html = parseMarkdownToHTML(markdown, filterRules);
248249
const tokens = parseHTMLToTokens(html);
249250
const tree = parseTokensToTree(tokens);
250251
const [text, ranges] = parseTreeToTextAndRanges(tree);

0 commit comments

Comments
 (0)