diff --git a/packages/editor/CodeMirror/markdown/markdownCommands.toggleList.test.ts b/packages/editor/CodeMirror/markdown/markdownCommands.toggleList.test.ts index c96bcfd59..a8e57bd90 100644 --- a/packages/editor/CodeMirror/markdown/markdownCommands.toggleList.test.ts +++ b/packages/editor/CodeMirror/markdown/markdownCommands.toggleList.test.ts @@ -232,4 +232,19 @@ describe('markdownCommands.toggleList', () => { ); expect(editor.state.selection.main.from).toBe(preSubListText.length); }); + + it('should not treat a list of IP addresses as a numbered list', async () => { + const initialDocText = '192.168.1.1. This\n127.0.0.1. is\n0.0.0.0. a list'; + + const editor = await createTestEditor( + initialDocText, + EditorSelection.range(0, initialDocText.length), + [], + ); + + toggleList(ListType.UnorderedList)(editor); + expect(editor.state.doc.toString()).toBe( + '- 192.168.1.1. This\n- 127.0.0.1. is\n- 0.0.0.0. a list', + ); + }); }); diff --git a/packages/editor/CodeMirror/markdown/markdownCommands.ts b/packages/editor/CodeMirror/markdown/markdownCommands.ts index 490a8faf1..a230d50c3 100644 --- a/packages/editor/CodeMirror/markdown/markdownCommands.ts +++ b/packages/editor/CodeMirror/markdown/markdownCommands.ts @@ -132,9 +132,9 @@ export const toggleList = (listType: ListType): Command => { // RegExps for different list types. The regular expressions MUST // be mutually exclusive. // `(?!\[[ xX]+\])` means "not followed by [x] or [ ]". - const bulletedRegex = /^\s*([-*])\s(?!\[[ xX]+\])/; - const checklistRegex = /^\s*[-*]\s\[[ xX]+\]\s?/; - const numberedRegex = /^\s*\d+\.\s?/; + const bulletedRegex = /^\s*([-*])\s(?!\[[ xX]+\]\s)/; + const checklistRegex = /^\s*[-*]\s\[[ xX]+\]\s/; + const numberedRegex = /^\s*\d+\.\s/; const listRegexes: Record = { [ListType.OrderedList]: numberedRegex,