mirror of
https://github.com/danbulant/lezer-markdown-obsidian
synced 2026-07-05 02:50:44 +00:00
simplify inline tex parsing
This commit is contained in:
parent
82886ae675
commit
71bf70e4d3
2 changed files with 6 additions and 6 deletions
|
|
@ -263,6 +263,8 @@ Line 5}
|
||||||
`
|
`
|
||||||
{P:plaintext {XI:{xm:$}tex content{xm:$}} more plaintext}
|
{P:plaintext {XI:{xm:$}tex content{xm:$}} more plaintext}
|
||||||
|
|
||||||
|
{P:plaintext {XI:{xm:$}tex content{xm:$}}more plaintext}
|
||||||
|
|
||||||
{P:{XI:{xm:$}1.234{xm:$}}}
|
{P:{XI:{xm:$}1.234{xm:$}}}
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -429,16 +429,14 @@ export const Tex: MarkdownConfig = {
|
||||||
{
|
{
|
||||||
name: "TexInline",
|
name: "TexInline",
|
||||||
parse(cx: InlineContext, next: number, pos: number) {
|
parse(cx: InlineContext, next: number, pos: number) {
|
||||||
let match = /^\$[^$\s]/.exec(cx.text.slice(pos - cx.offset));
|
let match = /^\$(?:[^$\t ][^$]*)?[^$\t \\]\$(\D|$)/.exec(
|
||||||
|
cx.text.slice(pos - cx.offset)
|
||||||
|
);
|
||||||
if (!match) {
|
if (!match) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const start = pos;
|
const start = pos;
|
||||||
match = /[^\t \\]\$(\D|$)/.exec(cx.text.slice(pos - cx.offset + 1));
|
const end = start + match[0].length - match[1].length;
|
||||||
if (!match) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const end = start + 1 + match.index + 2;
|
|
||||||
return cx.addElement(
|
return cx.addElement(
|
||||||
cx.elt("TexInline", start, end, [
|
cx.elt("TexInline", start, end, [
|
||||||
cx.elt("TexMarker", start, start + 1),
|
cx.elt("TexMarker", start, start + 1),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue