diff --git a/packages/app-cli/tests/html_to_md/escaped_format_characters.html b/packages/app-cli/tests/html_to_md/escaped_format_characters.html new file mode 100644 index 0000000000..00bdbfd0f7 --- /dev/null +++ b/packages/app-cli/tests/html_to_md/escaped_format_characters.html @@ -0,0 +1 @@ +

Some **format** characters $need$ to be `escaped`, if the characters were included directly in HTML.

diff --git a/packages/app-cli/tests/html_to_md/escaped_format_characters.md b/packages/app-cli/tests/html_to_md/escaped_format_characters.md new file mode 100644 index 0000000000..7eddd3a35b --- /dev/null +++ b/packages/app-cli/tests/html_to_md/escaped_format_characters.md @@ -0,0 +1 @@ +Some \*\*format\*\* characters \$need\$ to be \`escaped\`, if the characters were included directly in HTML. \ No newline at end of file diff --git a/packages/turndown/src/turndown.js b/packages/turndown/src/turndown.js index 86918ab664..b9d1aa71aa 100644 --- a/packages/turndown/src/turndown.js +++ b/packages/turndown/src/turndown.js @@ -18,7 +18,8 @@ var escapes = [ [/^>/g, '\\>'], // A list of valid \p values can be found here: https://unicode.org/reports/tr44/#GC_Values_Table [/(^|\p{Punctuation}|\p{Separator}|\p{Symbol})_(\P{Separator})/ug, '$1\\_$2'], - [/^(\d+)\. /g, '$1\\. '] + [/^(\d+)\. /g, '$1\\. '], + [/\$/g, '\\$$'], // Math ] export default function TurndownService (options) {