Skip to content

Commit

Permalink
Fix missing highlights on string tags
Browse files Browse the repository at this point in the history
Added highlighting for a=jump tags
  • Loading branch information
duckdoom4 committed Aug 7, 2024
1 parent fde7008 commit 7fbb036
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 65 deletions.
10 changes: 8 additions & 2 deletions examples/unit_test.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -954,11 +954,14 @@

# This line is incorrect, and will cause an error or incorrect
# behavior.
# "Plain {b}Bold {i}Bold-Italic{/b} Italic{/i} Plain"
"Plain {b}Bold {i}Bold-Italic{/b} Italic{/i} Plain"

"{a=https://renpy.org}Ren'Py's home page{/a}?" #test
"{a=https://renpy.org}Ren'Py' s home page?" #test

label test:

e "Why don't you visit {a=https://renpy.org}Ren'Py's home page{/a}?"
e "Why don't you visit {a=https://renpy.org}Ren'Py's home page{/a}?" #

e "Or {a=jump:more_text}here for more info{/a}."

Expand Down Expand Up @@ -996,6 +999,8 @@
"Let's have a {outlinecolor=#00ff00}Green{/outlinecolor} outline."

"{b}This is bold. {plain}This is not.{/plain} This is bold.{/b}"
"{b}This is bold. {plain}This is not. Plain till end of string.{/b}"
"{b}This is bold till end of string."

g "It's good {s}to see you{/s}."

Expand All @@ -1006,6 +1011,7 @@
g "It's good to {u}see{/u} you."

"Line 1{vspace=30}Line 2"
"Line 1{=mystyle}Line 2{/=mystyle}"

"New{#playlist}"

Expand Down
129 changes: 66 additions & 63 deletions syntaxes/renpy.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,16 @@
]
},
"escaped_char": {
"match": "(\\\\\")|(\\\\')|(\\\\ )|(\\\\n)|(\\\\\\\\)|(\\[\\[)|({{)",
"match": "(\\\\\")|(\\\\')|(\\\\ )|(\\\\n)|(\\\\\\\\)|(\\[\\[)|({{)|(%%)",
"captures": {
"1": { "name": "constant.character.escape.double-quote.python.renpy" },
"2": { "name": "constant.character.escape.quote.python.renpy" },
"3": { "name": "constant.character.escape.whitespace.python.renpy" },
"4": { "name": "constant.character.escape.newline.python.renpy" },
"5": { "name": "constant.character.escape.backslash.python.renpy" },
"6": { "name": "constant.character.escape.open.bracket.python.renpy" },
"7": { "name": "constant.character.escape.open.square-bracket.python.renpy" }
"7": { "name": "constant.character.escape.open.square-bracket.python.renpy" },
"8": { "name": "constant.character.escape.ampersand.python.renpy" }
}
},
"constant_placeholder": {
Expand Down Expand Up @@ -359,7 +360,7 @@
"string-tags-broken": {
"patterns": [
{
"comment": "Valid tags without params (close required)",
"comment": "Valid tags without params (optional close)",
"contentName": "renpy.meta.${2:/downcase} meta.tagged.string.renpy",
"begin": "({)\\s*(u|i|b|s|plain|alt|noalt|art|rb|rt)\\s*(})",
"beginCaptures": {
Expand All @@ -378,7 +379,7 @@
"patterns": [ { "include": "#strings-interior" } ]
},
{
"comment": "Valid tags with numeric params (close required)",
"comment": "Valid tags with numeric params (optional close)",
"contentName": "renpy.meta.${2:/downcase} meta.tagged.string.renpy",
"begin": "({)\\s*(alpha|cps|k)(=)(?:(\\*)|(\\-)|(\\+))?(\\d*(?:.\\d+)?)\\s*(})",
"beginCaptures": {
Expand All @@ -402,7 +403,7 @@
"patterns": [ { "include": "#strings-interior" } ]
},
{
"comment": "Valid tags with numeric params (close required)",
"comment": "Valid tags with numeric params (optional close)",
"contentName": "renpy.meta.${2:/downcase} meta.tagged.string.renpy",
"begin": "({)\\s*(size)(=)([\\-+]?)(\\d+)\\s*(})",
"beginCaptures": {
Expand All @@ -424,7 +425,7 @@
"patterns": [ { "include": "#strings-interior" } ]
},
{
"comment": "Valid tags with file param (close required)",
"comment": "Valid tags with file param (optional close)",
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"begin": "({)\\s*(font)(=)([\\w.]+)\\s*(})",
"beginCaptures": {
Expand Down Expand Up @@ -500,177 +501,179 @@
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"match": "({)\\s*(nw|done|fast|p|w|clear)\\s*(})",
"captures": {
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.definition.tag.end.renpy" }
"3": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with numeric params (self-closing)",
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"match": "({)\\s*(p|w)(=)(\\+?)(\\d*(?:.\\d+)?)\\s*(})",
"captures": {
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "keyword.operator.arithmetic.plus.renpy" },
"5": { "name": "support.constant.property-value.renpy constant.numeric.float.renpy" },
"6": { "name": "punctuation.definition.tag.end.renpy" }
"6": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with numeric params (self-closing)",
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"match": "({)\\s*(v?space)(=)(\\+?)(\\d+)\\s*(})",
"captures": {
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "keyword.operator.arithmetic.plus.renpy" },
"5": { "name": "support.constant.property-value.renpy constant.numeric.integer.renpy" },
"6": { "name": "punctuation.definition.tag.end.renpy" }
"6": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Comment tag (self-closing)",
"name": "meta.string.tag.comment.self-closing.renpy",
"match": "({)\\s*(#)\\s*(.*?)\\s*(})",
"captures": {
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "comment.line.number-sign.renpy punctuation.definition.comment.renpy" },
"3": { "name": "comment.line.number-sign.renpy" },
"4": { "name": "punctuation.definition.tag.end.renpy" }
"4": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with file param",
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"match": "({)\\s*(image)(=)([\\w.]+)\\s*(})",
"captures": {
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "support.constant.property-value.renpy string.unquoted.renpy" },
"5": { "name": "punctuation.definition.tag.end.renpy" }
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags without params (close required)",
"comment": "Valid tags without params (optional close)",
"match": "({)\\s*(u|i|b|s|plain|alt|noalt|art|rb|rt)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.definition.tag.end.renpy" }
"3": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with numeric params (close required)",
"comment": "Valid tags with numeric params (optional close)",
"match": "({)\\s*(alpha|cps|k)(=)(?:(\\*)|(\\-)|(\\+))?(\\d*(?:.\\d+)?)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "keyword.operator.arithmetic.Multiply.renpy" },
"5": { "name": "keyword.operator.arithmetic.Minus.renpy" },
"6": { "name": "keyword.operator.arithmetic.Plus.renpy" },
"7": { "name": "support.constant.property-value.renpy constant.numeric.renpy" },
"8": { "name": "punctuation.definition.tag.end.renpy" }
"8": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with numeric params (close required)",
"comment": "Valid tags with numeric params (optional close)",
"match": "({)\\s*(size)(=)([\\-+]?)(\\d+)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "keyword.operator.arithmetic.renpy" },
"5": { "name": "support.constant.property-value.renpy constant.numeric.integer.renpy" },
"6": { "name": "punctuation.definition.tag.end.renpy" }
"6": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Valid tags with file param (close required)",
"comment": "Valid tags with file param (optional close)",
"name": "meta.string.tag.${2:/downcase}.self-closing.renpy",
"match": "({)\\s*(font)(=)([\\w.]+)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "support.constant.property-value.renpy string.unquoted.renpy" },
"5": { "name": "punctuation.definition.tag.end.renpy" }
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Color tag",
"match": "({)\\s*(color|outlinecolor)(=)(#?[a-zA-Z0-9]+)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": {
"patterns": [ { "include": "#hex_literal" } ]
},
"5": { "name": "punctuation.definition.tag.end.renpy" }
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "a tag",
"match": "({)\\s*(a)(=)(.*?)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "support.constant.property-value.renpy string.unquoted.renpy" },
"5": { "name": "punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Unknown tag (Single line support only cus \\R does not work) (Since we don't know if a tag is self closing, we can't assume that an end pattern exists)",
"match": "({)[ \\t]*(\\w+)\\b(?:(=)(.*?))?\\s*(})((?:.|\\R)+?)\\s*({/)\\s*(\\2)\\s*(})",
"captures": {
"1": { "name": "meta.string.tag.${2:/downcase}.start.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "meta.string.tag.${2:/downcase}.start.renpy renpy.meta.u entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "meta.string.tag.${2:/downcase}.start.renpy punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "meta.string.tag.${2:/downcase}.start.renpy constant.other.placeholder.tags.renpy" },
"5": { "name": "meta.string.tag.${2:/downcase}.start.renpy punctuation.definition.tag.end.renpy" },
"6": {
"name": "renpy.meta.string.tag.custom.${2:/downcase} meta.tagged.string.renpy",
"patterns": [ { "include": "#strings-interior" } ]
"4": {
"patterns": [
{
"match": "\\b(jump)\\b(:)([[:alpha:]_]\\w*)",
"captures": {
"1": { "name": "keyword.control.flow.jump.renpy" },
"2": { "name": "punctuation.definition.jump.begin.renpy keyword.operator.jump.renpy" },
"3": {
"patterns": [
{ "include": "#label-name" },
{ "include": "#fallback-patterns" }
]
}
}
},
{
"match": ".*",
"name": "support.constant.property-value.renpy string.unquoted.renpy"
}
]
},
"7": { "name": "meta.string.tag.${2:/downcase}.end.renpy punctuation.definition.tag.begin.renpy" },
"8": { "name": "meta.string.tag.${2:/downcase}.end.renpy renpy.meta.u entity.name.tag.${2:/downcase}.renpy" },
"9": { "name": "meta.string.tag.${2:/downcase}.end.renpy punctuation.definition.tag.end.renpy" }
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Unknown tag start",
"match": "({)\\s*(\\w*)(?:(=)(.*?))?\\s*(})",
"comment": "Close tags",
"match": "({/)\\s*([[:alpha:]_]?\\w*)(=?)(.*?)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"0": { "name": "meta.string.tag.${2:/downcase}.end.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": {
"name": "support.constant.property-value.renpy constant.other.placeholder.tags.renpy"
},
"5": { "name": "punctuation.definition.tag.end.renpy" }
"4": { "name": "support.constant.property-value.renpy string.unquoted.renpy" },
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
},
{
"comment": "Unknown tag end",
"match": "({/)\\s*(\\w*?)\\b\\s*(})",
"comment": "Custom tags (optional close)",
"match": "({)\\s*([[:alpha:]_]?\\w*)(=?)(.*?)\\s*(})",
"captures": {
"0": { "name": "meta.string.tag.${2:/downcase}.end.renpy" },
"1": { "name": "punctuation.definition.tag.begin.renpy" },
"0": { "name": "meta.string.tag.${2:/downcase}.start.renpy" },
"1": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.begin.renpy" },
"2": { "name": "entity.name.tag.${2:/downcase}.renpy" },
"3": { "name": "punctuation.definition.tag.end.renpy" }
"3": { "name": "punctuation.separator.key-value.renpy keyword.operator.assignment.renpy" },
"4": { "name": "support.constant.property-value.renpy string.unquoted.renpy" },
"5": { "name": "constant.character.format.placeholder.other.renpy punctuation.definition.tag.end.renpy" }
}
}
]
Expand Down

0 comments on commit 7fbb036

Please sign in to comment.