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: $ => color_reference: $ =>
seq( prec.right(
field( seq(
'command', field(
choice('\\color', '\\colorbox', '\\textcolor', '\\pagecolor'), '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: $ => tikz_library_import: $ =>

@ -6513,42 +6513,92 @@
] ]
}, },
"color_reference": { "color_reference": {
"type": "SEQ", "type": "PREC_RIGHT",
"members": [ "value": 0,
{ "content": {
"type": "FIELD", "type": "SEQ",
"name": "command", "members": [
"content": { {
"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", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "STRING", "type": "FIELD",
"value": "\\color" "name": "name",
"content": {
"type": "SYMBOL",
"name": "curly_group_text"
}
}, },
{ {
"type": "STRING", "type": "SEQ",
"value": "\\colorbox" "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", "type": "FIELD",
"value": "\\textcolor" "name": "text",
"content": {
"type": "SYMBOL",
"name": "curly_group"
}
}, },
{ {
"type": "STRING", "type": "BLANK"
"value": "\\pagecolor"
} }
] ]
} }
}, ]
{ }
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "curly_group_text"
}
}
]
}, },
"tikz_library_import": { "tikz_library_import": {
"type": "SEQ", "type": "SEQ",

@ -1709,6 +1709,10 @@
"type": "\\colorbox", "type": "\\colorbox",
"named": false "named": false
}, },
{
"type": "\\mathcolor",
"named": false
},
{ {
"type": "\\pagecolor", "type": "\\pagecolor",
"named": false "named": false
@ -1719,15 +1723,45 @@
} }
] ]
}, },
"model": {
"multiple": false,
"required": false,
"types": [
{
"type": "brack_group_text",
"named": true
}
]
},
"name": { "name": {
"multiple": false, "multiple": false,
"required": true, "required": false,
"types": [ "types": [
{ {
"type": "curly_group_text", "type": "curly_group_text",
"named": true "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", "type": "\\let",
"named": false "named": false
}, },
{
"type": "\\mathcolor",
"named": false
},
{ {
"type": "\\nameCref", "type": "\\nameCref",
"named": false "named": false