From fa4e0ab1085b86d513c3548a761eea7a523724a8 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Thu, 9 Jul 2026 11:40:03 +0200 Subject: [PATCH] fix: list items don't highlight inline-flow elements (#47) Signed-off-by: squidfunk --- .../src/python-markdown.tmLanguage.yml | 28 +- .../test/snapshots/flow/list.scopes.json | 394 +++++++++++++++++- .../python-markdown/test/specs/flow/list.md | 20 + .../syntaxes/python-markdown.tmLanguage.json | 48 ++- 4 files changed, 466 insertions(+), 24 deletions(-) diff --git a/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml b/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml index ed756ad..68a023f 100644 --- a/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml +++ b/grammars/textmate/python-markdown/src/python-markdown.tmLanguage.yml @@ -533,34 +533,46 @@ repository: list_item: patterns: - - match: >- + - begin: >- (?:^|\G)([ \t]*)([*+-])([ ]+)(\[(?: |x|X)\])([ \t]+) - captures: + beginCaptures: 1: { name: punctuation.whitespace.leading.markdown } 2: { name: keyword.control.list.unordered.markdown } 3: { name: punctuation.whitespace.markdown } 4: { name: keyword.control.task-checkbox.markdown } 5: { name: punctuation.whitespace.markdown } - - match: >- + end: (?=$) + patterns: + - include: "#inline_flow" + - begin: >- (?:^|\G)([ \t]*)(\d+\.)([ ]+)(\[(?: |x|X)\])([ \t]+) - captures: + beginCaptures: 1: { name: punctuation.whitespace.leading.markdown } 2: { name: keyword.control.list.ordered.markdown } 3: { name: punctuation.whitespace.markdown } 4: { name: keyword.control.task-checkbox.markdown } 5: { name: punctuation.whitespace.markdown } - - match: >- + end: (?=$) + patterns: + - include: "#inline_flow" + - begin: >- (?:^|\G)([ \t]*)([*+-])([ ]+)(?=\S) - captures: + beginCaptures: 1: { name: punctuation.whitespace.leading.markdown } 2: { name: keyword.control.list.unordered.markdown } 3: { name: punctuation.whitespace.markdown } - - match: >- + end: (?=$) + patterns: + - include: "#inline_flow" + - begin: >- (?:^|\G)([ \t]*)(\d+\.)([ ]+)(?=\S) - captures: + beginCaptures: 1: { name: punctuation.whitespace.leading.markdown } 2: { name: keyword.control.list.ordered.markdown } 3: { name: punctuation.whitespace.markdown } + end: (?=$) + patterns: + - include: "#inline_flow" block_quote: patterns: diff --git a/grammars/textmate/python-markdown/test/snapshots/flow/list.scopes.json b/grammars/textmate/python-markdown/test/snapshots/flow/list.scopes.json index fb672d7..3583d1d 100644 --- a/grammars/textmate/python-markdown/test/snapshots/flow/list.scopes.json +++ b/grammars/textmate/python-markdown/test/snapshots/flow/list.scopes.json @@ -429,6 +429,326 @@ } ] }, + "inline": { + "accept_unordered_dash": [ + { + "line": "- __bold__ _italic_ `code`", + "tokens": [ + { + "text": "-", + "scopes": [ + "text.html.markdown.python", + "keyword.control.list.unordered.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python", + "punctuation.whitespace.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": "bold", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": "italic", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + }, + { + "text": "code", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + } + ] + }, + { + "line": "", + "tokens": [] + } + ], + "accept_unordered_asterisk": [ + { + "line": "* __bold__ _italic_ `code`", + "tokens": [ + { + "text": "*", + "scopes": [ + "text.html.markdown.python", + "keyword.control.list.unordered.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python", + "punctuation.whitespace.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": "bold", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": "italic", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + }, + { + "text": "code", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + } + ] + }, + { + "line": "", + "tokens": [] + } + ], + "accept_unordered_plus": [ + { + "line": "+ __bold__ _italic_ `code`", + "tokens": [ + { + "text": "+", + "scopes": [ + "text.html.markdown.python", + "keyword.control.list.unordered.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python", + "punctuation.whitespace.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": "bold", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown" + ] + }, + { + "text": "__", + "scopes": [ + "text.html.markdown.python", + "markup.bold.markdown", + "punctuation.definition.bold.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": "italic", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown" + ] + }, + { + "text": "_", + "scopes": [ + "text.html.markdown.python", + "markup.italic.markdown", + "punctuation.definition.italic.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + }, + { + "text": "code", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown" + ] + }, + { + "text": "`", + "scopes": [ + "text.html.markdown.python", + "markup.inline.raw.string.markdown", + "punctuation.definition.raw.markdown" + ] + } + ] + }, + { + "line": "", + "tokens": [] + } + ] + }, "rejection": { "reject_marker_missing_space": [ { @@ -467,9 +787,27 @@ ] }, { - "text": "[ ]", + "text": "[", "scopes": [ - "text.html.markdown.python" + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.begin.markdown" + ] + }, + { + "text": " ", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "string.other.link.title.markdown" + ] + }, + { + "text": "]", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.end.markdown" ] } ] @@ -498,7 +836,31 @@ ] }, { - "text": "[y] Task", + "text": "[", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.begin.markdown" + ] + }, + { + "text": "y", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "string.other.link.title.markdown" + ] + }, + { + "text": "]", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.end.markdown" + ] + }, + { + "text": " Task", "scopes": [ "text.html.markdown.python" ] @@ -529,7 +891,31 @@ ] }, { - "text": "[x]Task", + "text": "[", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.begin.markdown" + ] + }, + { + "text": "x", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "string.other.link.title.markdown" + ] + }, + { + "text": "]", + "scopes": [ + "text.html.markdown.python", + "meta.link.reference.markdown", + "punctuation.definition.link.end.markdown" + ] + }, + { + "text": "Task", "scopes": [ "text.html.markdown.python" ] diff --git a/grammars/textmate/python-markdown/test/specs/flow/list.md b/grammars/textmate/python-markdown/test/specs/flow/list.md index 9b5111b..92aeb0b 100644 --- a/grammars/textmate/python-markdown/test/specs/flow/list.md +++ b/grammars/textmate/python-markdown/test/specs/flow/list.md @@ -68,6 +68,26 @@ - [ ] ``` +## inline + +### accept_unordered_dash + +``` md +- __bold__ _italic_ `code` +``` + +### accept_unordered_asterisk + +``` md +* __bold__ _italic_ `code` +``` + +### accept_unordered_plus + +``` md ++ __bold__ _italic_ `code` +``` + ## rejection ### reject_marker_missing_space diff --git a/integrations/code/syntaxes/python-markdown.tmLanguage.json b/integrations/code/syntaxes/python-markdown.tmLanguage.json index 8467ee0..2ba5149 100644 --- a/integrations/code/syntaxes/python-markdown.tmLanguage.json +++ b/integrations/code/syntaxes/python-markdown.tmLanguage.json @@ -5997,8 +5997,8 @@ "list_item": { "patterns": [ { - "match": "(?:^|\\G)([ \\t]*)([*+-])([ ]+)(\\[(?: |x|X)\\])([ \\t]+)", - "captures": { + "begin": "(?:^|\\G)([ \\t]*)([*+-])([ ]+)(\\[(?: |x|X)\\])([ \\t]+)", + "beginCaptures": { "1": { "name": "punctuation.whitespace.leading.markdown" }, @@ -6014,11 +6014,17 @@ "5": { "name": "punctuation.whitespace.markdown" } - } + }, + "end": "(?=$)", + "patterns": [ + { + "include": "#inline_flow" + } + ] }, { - "match": "(?:^|\\G)([ \\t]*)(\\d+\\.)([ ]+)(\\[(?: |x|X)\\])([ \\t]+)", - "captures": { + "begin": "(?:^|\\G)([ \\t]*)(\\d+\\.)([ ]+)(\\[(?: |x|X)\\])([ \\t]+)", + "beginCaptures": { "1": { "name": "punctuation.whitespace.leading.markdown" }, @@ -6034,11 +6040,17 @@ "5": { "name": "punctuation.whitespace.markdown" } - } + }, + "end": "(?=$)", + "patterns": [ + { + "include": "#inline_flow" + } + ] }, { - "match": "(?:^|\\G)([ \\t]*)([*+-])([ ]+)(?=\\S)", - "captures": { + "begin": "(?:^|\\G)([ \\t]*)([*+-])([ ]+)(?=\\S)", + "beginCaptures": { "1": { "name": "punctuation.whitespace.leading.markdown" }, @@ -6048,11 +6060,17 @@ "3": { "name": "punctuation.whitespace.markdown" } - } + }, + "end": "(?=$)", + "patterns": [ + { + "include": "#inline_flow" + } + ] }, { - "match": "(?:^|\\G)([ \\t]*)(\\d+\\.)([ ]+)(?=\\S)", - "captures": { + "begin": "(?:^|\\G)([ \\t]*)(\\d+\\.)([ ]+)(?=\\S)", + "beginCaptures": { "1": { "name": "punctuation.whitespace.leading.markdown" }, @@ -6062,7 +6080,13 @@ "3": { "name": "punctuation.whitespace.markdown" } - } + }, + "end": "(?=$)", + "patterns": [ + { + "include": "#inline_flow" + } + ] } ] },