Skip to content

Add (optional?) support for +tex_math_single_backslash extension #154

Closed
@jez

Description

@jez

pandoc supports a number of optional syntax extensions, one of which I use frequently: inline math through the \( ... \) syntax. It'd be great if the pandocLaTeXInlineMath region supported this alternative syntax as well.

I tried implementing it myself:

diff --git a/syntax/pandoc.vim b/syntax/pandoc.vim
index 759ebbb..185b378 100644
--- a/syntax/pandoc.vim
+++ b/syntax/pandoc.vim
@@ -210,7 +210,7 @@ call s:WithConceal('html_c_e', 'syn match pandocHTMLCommentEnd /-->/ contained',
 " Unset current_syntax so the 2nd include will work
 unlet b:current_syntax
 syn include @LATEX syntax/tex.vim
-syn region pandocLaTeXInlineMath start=/\\\@<!\$[[:graph:]]\@=/ end=/\\\@<!\$/ keepend contains=@LATEX 
+syn region pandocLaTeXInlineMath start=/\\\@<!\(\$|\\(\)[[:graph:]]\@=/ end=/\\\@<!\(\$|\\)\)/ keepend contains=@LATEX 
 syn match pandocProtectedFromInlineLaTeX /\\\@<!\${.*}\(\(\s\|[[:punct:]]\)\([^$]*\|.*\(\\\$.*\)\{2}\)\n\n\|$\)\@=/ display
 " contains=@LATEX
 syn region pandocLaTeXMathBlock start=/\$\$/ end=/\$\$/ keepend contains=@LATEX

But this solution behaves weirdly with respect to cases like the following:

\(x$

where the same delimiter isn't used on both ends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions