feat: support TrustedValue · azu/markdown-function@3037c50

Original file line numberDiff line numberDiff line change

@@ -1,3 +1,5 @@

1+

import { isTrustedValue, TrustedValue } from "./trusted";

2+
13

const replacementsTuples: [matchPattern: RegExp, newChar: string][] = [

24

[/\*/g, "\\*"],

35

[/#/g, "\\#"],

@@ -10,7 +12,10 @@ const replacementsTuples: [matchPattern: RegExp, newChar: string][] = [

1012

[/>/g, ">"],

1113

[/_/g, "\\_"]

1214

];

13-

export const mdEscape = (text: string): string => {

15+

export const mdEscape = (text: string | TrustedValue): string => {

16+

if (isTrustedValue(text)) {

17+

return text.value;

18+

}

1419

return replacementsTuples.reduce((text, replacement) => {

1520

return text.replace(replacement[0], replacement[1]);

1621

}, text);