mirror of
https://github.com/danbulant/lezer-markdown-obsidian
synced 2026-06-18 22:11:22 +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:{XI:{xm:$}1.234{xm:$}}}
|
||||
`
|
||||
);
|
||||
|
|
|
|||
|
|
@ -429,16 +429,14 @@ export const Tex: MarkdownConfig = {
|
|||
{
|
||||
name: "TexInline",
|
||||
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) {
|
||||
return -1;
|
||||
}
|
||||
const start = pos;
|
||||
match = /[^\t \\]\$(\D|$)/.exec(cx.text.slice(pos - cx.offset + 1));
|
||||
if (!match) {
|
||||
return -1;
|
||||
}
|
||||
const end = start + 1 + match.index + 2;
|
||||
const end = start + match[0].length - match[1].length;
|
||||
return cx.addElement(
|
||||
cx.elt("TexInline", start, end, [
|
||||
cx.elt("TexMarker", start, start + 1),
|
||||
|
|
|
|||
Loading…
Reference in a new issue