From fdf6effd372d5072944f31c4c3766fc59c8e5667 Mon Sep 17 00:00:00 2001 From: tanhakabir Date: Fri, 8 Oct 2021 16:51:45 -0700 Subject: [PATCH 1/2] Add rule for paths with spaces. Correct in inspect scope but incorrect in generated testcase --- markdown.tmLanguage.base.yaml | 10 +++ syntaxes/markdown.tmLanguage | 37 ++++++++ test/colorize-fixtures/issue-80.md | 1 + test/colorize-results/issue-80_md.json | 112 +++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 test/colorize-fixtures/issue-80.md create mode 100644 test/colorize-results/issue-80_md.json diff --git a/markdown.tmLanguage.base.yaml b/markdown.tmLanguage.base.yaml index 1e1c909..619fd50 100644 --- a/markdown.tmLanguage.base.yaml +++ b/markdown.tmLanguage.base.yaml @@ -221,6 +221,7 @@ repository: - {include: '#link-ref'} - {include: '#link-ref-literal'} - {include: '#link-ref-shortcut'} + - {include: '#link-html'} ampersand: comment: "Markdown will convert this for us. We match it so that the HTML grammar will not mark it up as invalid." match: '&(?!([a-zA-Z0-9]+|#[0-9]+|#x[0-9a-fA-F]+);)' @@ -291,6 +292,7 @@ repository: - {include: '#link-ref-literal'} - {include: '#link-ref'} - {include: '#link-ref-shortcut'} + - {include: '#link-html'} bracket: comment: "Markdown will convert this for us. We match it so that the HTML grammar will not mark it up as invalid." match: '<(?![a-zA-Z/?\$!])' @@ -406,6 +408,7 @@ repository: - {include: '#link-ref-literal'} - {include: '#link-ref'} - {include: '#link-ref-shortcut'} + - {include: '#link-html'} link-email: captures: '1': {name: punctuation.definition.link.markdown} @@ -480,6 +483,13 @@ repository: '3': {name: punctuation.definition.string.end.markdown} match: (\[)(\S+?)(\]) name: meta.link.reference.markdown + link-html: + captures: + '1': {name: punctuation.definition.link.markdown} + '2': {name: markup.underline.link.markdown} + '3': {name: punctuation.definition.link.markdown} + match: (?<=\[.*\]\()(\<)(.*?)(\>) + name: meta.link.inline.markdown raw: captures: '1': {name: punctuation.definition.raw.markdown} diff --git a/syntaxes/markdown.tmLanguage b/syntaxes/markdown.tmLanguage index c40ec43..1da590b 100644 --- a/syntaxes/markdown.tmLanguage +++ b/syntaxes/markdown.tmLanguage @@ -3764,6 +3764,10 @@ include #link-ref-shortcut + + include + #link-html + ampersand @@ -3902,6 +3906,10 @@ include #link-ref-shortcut + + include + #link-html + bracket @@ -4193,6 +4201,10 @@ include #link-ref-shortcut + + include + #link-html + link-email @@ -4453,6 +4465,31 @@ name meta.link.reference.markdown + link-html + + captures + + 1 + + name + punctuation.definition.link.markdown + + 2 + + name + markup.underline.link.markdown + + 3 + + name + punctuation.definition.link.markdown + + + match + (?<=\[.*\]\()(\<)(.*?)(\>) + name + meta.link.inline.markdown + raw captures diff --git a/test/colorize-fixtures/issue-80.md b/test/colorize-fixtures/issue-80.md new file mode 100644 index 0000000..62231c6 --- /dev/null +++ b/test/colorize-fixtures/issue-80.md @@ -0,0 +1 @@ +[title] \ No newline at end of file diff --git a/test/colorize-results/issue-80_md.json b/test/colorize-results/issue-80_md.json new file mode 100644 index 0000000..fc75834 --- /dev/null +++ b/test/colorize-results/issue-80_md.json @@ -0,0 +1,112 @@ +[ + { + "c": "[", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.begin.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "title", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown string.other.link.title.markdown", + "r": { + "dark_plus": "string: #CE9178", + "light_plus": "string: #A31515", + "dark_vs": "string: #CE9178", + "light_vs": "string: #A31515", + "hc_black": "string: #CE9178" + } + }, + { + "c": "]", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.end.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "<", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html", + "r": { + "dark_plus": "punctuation.definition.tag: #808080", + "light_plus": "punctuation.definition.tag: #800000", + "dark_vs": "punctuation.definition.tag: #808080", + "light_vs": "punctuation.definition.tag: #800000", + "hc_black": "punctuation.definition.tag: #808080" + } + }, + { + "c": "path", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative entity.name.tag.html", + "r": { + "dark_plus": "entity.name.tag: #569CD6", + "light_plus": "entity.name.tag: #800000", + "dark_vs": "entity.name.tag: #569CD6", + "light_vs": "entity.name.tag: #800000", + "hc_black": "entity.name.tag: #569CD6" + } + }, + { + "c": " ", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "with", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative meta.attribute.unrecognized.with.html entity.other.attribute-name.html", + "r": { + "dark_plus": "entity.other.attribute-name: #9CDCFE", + "light_plus": "entity.other.attribute-name: #FF0000", + "dark_vs": "entity.other.attribute-name: #9CDCFE", + "light_vs": "entity.other.attribute-name: #FF0000", + "hc_black": "entity.other.attribute-name: #9CDCFE" + } + }, + { + "c": " ", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "spaces", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative meta.attribute.unrecognized.spaces.html entity.other.attribute-name.html", + "r": { + "dark_plus": "entity.other.attribute-name: #9CDCFE", + "light_plus": "entity.other.attribute-name: #FF0000", + "dark_vs": "entity.other.attribute-name: #9CDCFE", + "light_vs": "entity.other.attribute-name: #FF0000", + "hc_black": "entity.other.attribute-name: #9CDCFE" + } + }, + { + "c": ">", + "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html", + "r": { + "dark_plus": "punctuation.definition.tag: #808080", + "light_plus": "punctuation.definition.tag: #800000", + "dark_vs": "punctuation.definition.tag: #808080", + "light_vs": "punctuation.definition.tag: #800000", + "hc_black": "punctuation.definition.tag: #808080" + } + } +] \ No newline at end of file From 82e95b6b193d84bb91094e27ddd752be1c557dbb Mon Sep 17 00:00:00 2001 From: tanhakabir Date: Thu, 14 Oct 2021 09:26:03 -0700 Subject: [PATCH 2/2] Fix error in testcase and add more cases to testcase --- test/colorize-fixtures/issue-80.md | 6 +- test/colorize-results/issue-80_md.json | 203 ++++++++++++++++++++----- 2 files changed, 167 insertions(+), 42 deletions(-) diff --git a/test/colorize-fixtures/issue-80.md b/test/colorize-fixtures/issue-80.md index 62231c6..35caf41 100644 --- a/test/colorize-fixtures/issue-80.md +++ b/test/colorize-fixtures/issue-80.md @@ -1 +1,5 @@ -[title] \ No newline at end of file +[text](link) + +[text]() + +[title]() \ No newline at end of file diff --git a/test/colorize-results/issue-80_md.json b/test/colorize-results/issue-80_md.json index fc75834..352e941 100644 --- a/test/colorize-results/issue-80_md.json +++ b/test/colorize-results/issue-80_md.json @@ -1,7 +1,7 @@ [ { "c": "[", - "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.begin.markdown", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.string.begin.markdown", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -11,8 +11,8 @@ } }, { - "c": "title", - "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown string.other.link.title.markdown", + "c": "text", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown string.other.link.title.markdown", "r": { "dark_plus": "string: #CE9178", "light_plus": "string: #A31515", @@ -23,7 +23,84 @@ }, { "c": "]", - "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.end.markdown", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.string.end.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "(", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.metadata.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "link", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown markup.underline.link.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": ")", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.metadata.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "[", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.string.begin.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "text", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown string.other.link.title.markdown", + "r": { + "dark_plus": "string: #CE9178", + "light_plus": "string: #A31515", + "dark_vs": "string: #CE9178", + "light_vs": "string: #A31515", + "hc_black": "string: #CE9178" + } + }, + { + "c": "]", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.string.end.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "(", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.metadata.markdown", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -34,29 +111,62 @@ }, { "c": "<", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.begin.html", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.link.markdown", "r": { - "dark_plus": "punctuation.definition.tag: #808080", - "light_plus": "punctuation.definition.tag: #800000", - "dark_vs": "punctuation.definition.tag: #808080", - "light_vs": "punctuation.definition.tag: #800000", - "hc_black": "punctuation.definition.tag: #808080" + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "link>", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown markup.underline.link.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": ")", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.metadata.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": "[", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.begin.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" } }, { - "c": "path", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative entity.name.tag.html", + "c": "title", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown string.other.link.title.markdown", "r": { - "dark_plus": "entity.name.tag: #569CD6", - "light_plus": "entity.name.tag: #800000", - "dark_vs": "entity.name.tag: #569CD6", - "light_vs": "entity.name.tag: #800000", - "hc_black": "entity.name.tag: #569CD6" + "dark_plus": "string: #CE9178", + "light_plus": "string: #A31515", + "dark_vs": "string: #CE9178", + "light_vs": "string: #A31515", + "hc_black": "string: #CE9178" } }, { - "c": " ", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative", + "c": "]", + "t": "text.html.markdown meta.paragraph.markdown meta.link.reference.markdown punctuation.definition.string.end.markdown", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -66,19 +176,19 @@ } }, { - "c": "with", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative meta.attribute.unrecognized.with.html entity.other.attribute-name.html", + "c": "(", + "t": "text.html.markdown meta.paragraph.markdown", "r": { - "dark_plus": "entity.other.attribute-name: #9CDCFE", - "light_plus": "entity.other.attribute-name: #FF0000", - "dark_vs": "entity.other.attribute-name: #9CDCFE", - "light_vs": "entity.other.attribute-name: #FF0000", - "hc_black": "entity.other.attribute-name: #9CDCFE" + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" } }, { - "c": " ", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative", + "c": "<", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.link.markdown", "r": { "dark_plus": "default: #D4D4D4", "light_plus": "default: #000000", @@ -88,25 +198,36 @@ } }, { - "c": "spaces", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative meta.attribute.unrecognized.spaces.html entity.other.attribute-name.html", + "c": "path with spaces", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown markup.underline.link.markdown", "r": { - "dark_plus": "entity.other.attribute-name: #9CDCFE", - "light_plus": "entity.other.attribute-name: #FF0000", - "dark_vs": "entity.other.attribute-name: #9CDCFE", - "light_vs": "entity.other.attribute-name: #FF0000", - "hc_black": "entity.other.attribute-name: #9CDCFE" + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" } }, { "c": ">", - "t": "text.html.markdown meta.paragraph.markdown meta.tag.other.unrecognized.html.derivative punctuation.definition.tag.end.html", + "t": "text.html.markdown meta.paragraph.markdown meta.link.inline.markdown punctuation.definition.link.markdown", "r": { - "dark_plus": "punctuation.definition.tag: #808080", - "light_plus": "punctuation.definition.tag: #800000", - "dark_vs": "punctuation.definition.tag: #808080", - "light_vs": "punctuation.definition.tag: #800000", - "hc_black": "punctuation.definition.tag: #808080" + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" + } + }, + { + "c": ")", + "t": "text.html.markdown meta.paragraph.markdown", + "r": { + "dark_plus": "default: #D4D4D4", + "light_plus": "default: #000000", + "dark_vs": "default: #D4D4D4", + "light_vs": "default: #000000", + "hc_black": "default: #FFFFFF" } } ] \ No newline at end of file