Better color reference (#151)

- add `\mathcolor`
- support directly passing color scheme and spec
- (optionally) include following argument

Signed-off-by: Jonas Dujava <jonas.dujava@gmail.com>
pull/813/head
Jonáš Dujava 2024-07-23 09:16:06 +07:00 committed by GitHub
parent 81acebb480
commit 6706f88d5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 128 additions and 31 deletions

@ -1188,12 +1188,21 @@ module.exports = grammar({
),
color_reference: $ =>
seq(
field(
'command',
choice('\\color', '\\colorbox', '\\textcolor', '\\pagecolor'),
prec.right(
seq(
field(
'command',
choice('\\color', '\\pagecolor', '\\textcolor', '\\mathcolor','\\colorbox'),
),
choice(
field('name', $.curly_group_text),
seq(
field('model', $.brack_group_text),
field('spec', $.curly_group),
),
),
optional(field('text', $.curly_group)),
),
field('name', $.curly_group_text),
),
tikz_library_import: $ =>

@ -6513,42 +6513,92 @@
]
},
"color_reference": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "command",
"content": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "command",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\\color"
},
{
"type": "STRING",
"value": "\\pagecolor"
},
{
"type": "STRING",
"value": "\\textcolor"
},
{
"type": "STRING",
"value": "\\mathcolor"
},
{
"type": "STRING",
"value": "\\colorbox"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\\color"
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "curly_group_text"
}
},
{
"type": "STRING",
"value": "\\colorbox"
},
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "model",
"content": {
"type": "SYMBOL",
"name": "brack_group_text"
}
},
{
"type": "FIELD",
"name": "spec",
"content": {
"type": "SYMBOL",
"name": "curly_group"
}
}
]
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "\\textcolor"
"type": "FIELD",
"name": "text",
"content": {
"type": "SYMBOL",
"name": "curly_group"
}
},
{
"type": "STRING",
"value": "\\pagecolor"
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "curly_group_text"
}
}
]
]
}
},
"tikz_library_import": {
"type": "SEQ",

@ -1709,6 +1709,10 @@
"type": "\\colorbox",
"named": false
},
{
"type": "\\mathcolor",
"named": false
},
{
"type": "\\pagecolor",
"named": false
@ -1719,15 +1723,45 @@
}
]
},
"model": {
"multiple": false,
"required": false,
"types": [
{
"type": "brack_group_text",
"named": true
}
]
},
"name": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "curly_group_text",
"named": true
}
]
},
"spec": {
"multiple": false,
"required": false,
"types": [
{
"type": "curly_group",
"named": true
}
]
},
"text": {
"multiple": false,
"required": false,
"types": [
{
"type": "curly_group",
"named": true
}
]
}
}
},
@ -9221,6 +9255,10 @@
"type": "\\let",
"named": false
},
{
"type": "\\mathcolor",
"named": false
},
{
"type": "\\nameCref",
"named": false