@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
99import { mocked } from "jest-mock" ;
1010
1111import EditorModel from "../../../src/editor/model" ;
12- import { htmlSerializeIfNeeded } from "../../../src/editor/serialize" ;
12+ import { htmlSerializeFromMdIfNeeded , htmlSerializeIfNeeded } from "../../../src/editor/serialize" ;
1313import { createPartCreator } from "./mock" ;
1414import { IConfigOptions } from "../../../src/IConfigOptions" ;
1515import SettingsStore from "../../../src/settings/SettingsStore" ;
@@ -71,6 +71,12 @@ describe("editor/serialize", function () {
7171 const html = htmlSerializeIfNeeded ( model , { } ) ;
7272 expect ( html ) . toBe ( "*hello* world" ) ;
7373 } ) ;
74+ it ( "escaped markdown should not retain backslashes around other markdown" , function ( ) {
75+ const pc = createPartCreator ( ) ;
76+ const model = new EditorModel ( [ pc . plain ( "\\*hello\\* **world**" ) ] , pc ) ;
77+ const html = htmlSerializeIfNeeded ( model , { } ) ;
78+ expect ( html ) . toBe ( "*hello* <strong>world</strong>" ) ;
79+ } ) ;
7480 it ( "escaped markdown should convert HTML entities" , function ( ) {
7581 const pc = createPartCreator ( ) ;
7682 const model = new EditorModel ( [ pc . plain ( "\\*hello\\* world < hey world!" ) ] , pc ) ;
@@ -153,6 +159,14 @@ describe("editor/serialize", function () {
153159 const html = htmlSerializeIfNeeded ( model , { forceHTML : true , useMarkdown : false } ) ;
154160 expect ( html ) . toBe ( "hello world" ) ;
155161 } ) ;
162+ it ( "should treat tags not in allowlist as plaintext" , ( ) => {
163+ const html = htmlSerializeFromMdIfNeeded ( "<b>test</b>" , { } ) ;
164+ expect ( html ) . toBeUndefined ( ) ;
165+ } ) ;
166+ it ( "should treat tags not in allowlist as plaintext even if escaped" , ( ) => {
167+ const html = htmlSerializeFromMdIfNeeded ( "\\<b>test</b>" , { } ) ;
168+ expect ( html ) . toBe ( "<b>test</b>" ) ;
169+ } ) ;
156170 } ) ;
157171
158172 describe ( "feature_latex_maths" , ( ) => {
0 commit comments