Fix a few more cases of math block highlighting

Fixes #135254
This commit is contained in:
Matt Bierner 2021-10-20 15:56:07 -07:00
parent 3eeb80e04e
commit 17dc026824
No known key found for this signature in database
GPG key ID: 099C331567E11888
4 changed files with 1373 additions and 161 deletions

View file

@ -13,42 +13,70 @@
"double_dollar_math_block": {
"name": "markup.math.block.markdown",
"contentName": "meta.embedded.math.markdown",
"begin": "(?<=^\\s*)(\\${2})",
"begin": "(?<=^\\s*)(\\${2})(?![^$]*\\${2})",
"beginCaptures": {
"1": {
"name": "punctuation.definition.math.begin.markdown"
}
},
"end": "(\\${2})",
"end": "(.*)(\\${2})",
"endCaptures": {
"1": {
"name": "meta.embedded.math.markdown",
"patterns": [
{
"include": "text.html.markdown.math#math"
}
]
},
"2": {
"name": "punctuation.definition.math.end.markdown"
}
},
"patterns": [
{
"include": "text.html.markdown.math#math"
"begin": "(^|\\G)",
"while": "(^|\\G)(?!.*(\\${2}))",
"patterns": [
{
"include": "text.html.markdown.math#math"
}
]
}
]
},
"single_dollar_math_block": {
"name": "markup.math.block.markdown",
"contentName": "meta.embedded.math.markdown",
"begin": "(?<=^\\s*)(\\${1})",
"begin": "(?<=^\\s*)(\\${1})(?![^$]*\\${1})",
"beginCaptures": {
"1": {
"name": "punctuation.definition.math.begin.markdown"
}
},
"end": "(\\${1})",
"end": "(.*)(\\${1})",
"endCaptures": {
"1": {
"name": "meta.embedded.math.markdown",
"patterns": [
{
"include": "text.html.markdown.math#math"
}
]
},
"2": {
"name": "punctuation.definition.math.end.markdown"
}
},
"patterns": [
{
"include": "text.html.markdown.math#math"
"begin": "(^|\\G)",
"while": "(^|\\G)(?!.*(\\${1}))",
"patterns": [
{
"include": "text.html.markdown.math#math"
}
]
}
]
}

View file

@ -4,6 +4,9 @@
"patterns": [
{
"include": "#math_inline"
},
{
"include": "#math_inline_block"
}
],
"repository": {
@ -26,6 +29,27 @@
"name": "punctuation.definition.math.begin.markdown"
}
}
},
"math_inline_block": {
"name": "markup.math.inline.markdown",
"contentName": "meta.embedded.math.markdown",
"begin": "(?<=\\s|^)(\\${2})",
"beginCaptures": {
"2": {
"name": "punctuation.definition.math.begin.markdown"
}
},
"end": "(\\${2})(?=\\s|$)",
"endCaptures": {
"2": {
"name": "punctuation.definition.math.end.markdown"
}
},
"patterns": [
{
"include": "text.html.markdown.math#math"
}
]
}
},
"scopeName": "markdown.math.inline"

View file

@ -4,11 +4,13 @@ $$
\theta
$$
**md**
$$
\theta{ % comment
$$
**a**
**md**
$$
\relax{x}{1} = \int_{-\infty}^\infty
@ -16,10 +18,14 @@ $$
\,d\xi % comment
$$
**md**
$
x = 1.1 \int_{a}
$
**md**
$
\begin{smallmatrix}
1 & 2 \\
@ -57,13 +63,15 @@ a **a**$ \theta $aa a **a**
a **a**$$ \theta $$aa a **a**
<!-- Should be disabled in comments -->
<!--
$$
\theta % comment
$$
-->
Should be disabled in fenced code blocks:
<!-- Should be disabled in fenced code blocks -->
```txt
$$
@ -106,10 +114,40 @@ $$
$$ \vec{a}
\vec{a}
= [2, 3] $$
\vec{a} $$
**md**
$ \vec{a}
\vec{a}
\vec{a} $
**md**
\vec{a}
**md**
$ \vec{a}
\vec{a}
= [2, 3] $
<!-- Should highlight inline blocks -->
a **b** $$
**b**
**md**
a **b** $$
\frac{1}{2}
$$
**b**
**p**
a **b**
$$
\frac{1}{2}
$$
**b**