diff --git a/apps/editor/src/js/convertor.js b/apps/editor/src/js/convertor.js index 6124c31d45..09f0b25d89 100644 --- a/apps/editor/src/js/convertor.js +++ b/apps/editor/src/js/convertor.js @@ -20,6 +20,7 @@ const openingTag = `(\\\\<|<)([A-Za-z][A-Za-z0-9\\-]*${attribute})(\\/?>)`; const HTML_TAG_RX = new RegExp(openingTag, 'g'); const FRONT_MATTER_RX = /^\s?\\-\\-\\-([\s\S]+?)\\-\\-\\-/; const NBSP_RX = / /g; +const BULLET_LIST_WITH_ORDERED_NUM_RX = /^(\s*\*\s+\d+)\./g; /** * Class Convertor @@ -77,9 +78,11 @@ class Convertor { * @private */ _markdownToHtml(markdown) { - markdown = markdown.replace(HTML_TAG_RX, (match, $1, $2, $3) => - match[0] !== '\\' ? `${$1}${$2} data-tomark-pass ${$3}` : match - ); + markdown = markdown + .replace(HTML_TAG_RX, (match, $1, $2, $3) => + match[0] !== '\\' ? `${$1}${$2} data-tomark-pass ${$3}` : match + ) + .replace(BULLET_LIST_WITH_ORDERED_NUM_RX, '$1\\.'); return this.renderHTML(this.mdReader.parse(markdown)); } diff --git a/apps/editor/test/unit/convertor.spec.js b/apps/editor/test/unit/convertor.spec.js index 4ee69a53dd..2b16ebb47c 100644 --- a/apps/editor/test/unit/convertor.spec.js +++ b/apps/editor/test/unit/convertor.spec.js @@ -174,6 +174,23 @@ describe('Convertor', () => { expect(convertor.toHTML(taskItemMd)).toBe(expectedHTML); }); + + it('bullet list item having the ordered num contents should be converted as the bullet list item(not ordered list item)', () => { + const listItemMd = ['* 1. ordered num', ' * child1', ' * child2'].join('\n'); + const expectedHTML = [ + '', + '' + ].join('\n'); + + expect(convertor.toHTML(listItemMd)).toBe(expectedHTML); + }); }); describe('html to markdown', () => {