From 323f06c4493136f581fb0d41be99036b823ff77d Mon Sep 17 00:00:00 2001 From: Jake Zimmerman Date: Mon, 19 Jan 2026 18:26:54 -0800 Subject: [PATCH] Simplify the delimited codeblock regex The regex: `{3,}`* Means "three or more copies of a backtick, followed by zero or more copies of a backtick." Similarly, the regex: \~{3,}\~* Is the same, but with the tilde character. It looks like the original author of this regex might have misunderstood the regex repetition operator, thinking that `{3,}` means "exactly three copies," or possibly an earlier version of this regex might have forcibly enabled Vim's support for non-greedy matches. Regardless, the trailing `*` regex operator for matching zero or more copies is redundant and can be removed. This might translate to a minor performance improvement, but I have not attempted to measure that. --- syntax/pandoc.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/pandoc.vim b/syntax/pandoc.vim index 90caeb3..6235e80 100644 --- a/syntax/pandoc.vim +++ b/syntax/pandoc.vim @@ -445,11 +445,11 @@ syn match pandocTableHeaderWord /\<.\{-}\>/ contained containedin=pandocGridTabl " Delimited Code Blocks: {{{2 " this is here because we can override strikeouts and subscripts -syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\+\|\t\)\=\~\{3,}\~*\)/ end=/^\z1\~*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend -syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\+\|\t\)\=`\{3,}`*\)/ end=/^\z1`*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend +syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\( \+\|\t\)\=\~\{3,}\)/ end=/^\z1\~*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend +syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\( \+\|\t\)\=`\{3,}\)/ end=/^\z1`*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend call s:WithConceal('codeblock_start', 'syn match pandocDelimitedCodeBlockStart /\(\(\_^\n\_^\|\%^\)\(>\s\)\?\( \+\|\t\)\=\)\@<=\(\~\{3,}\~*\|`\{3,}`*\)/ contained containedin=pandocDelimitedCodeBlock nextgroup=pandocDelimitedCodeBlockLanguage', 'conceal cchar='.s:cchars['codelang']) syn match pandocDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained -call s:WithConceal('codeblock_delim', 'syn match pandocDelimitedCodeBlockEnd /\(`\{3,}`*\|\~\{3,}\~*\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock', 'conceal cchar='.s:cchars['codeend']) +call s:WithConceal('codeblock_delim', 'syn match pandocDelimitedCodeBlockEnd /\(`\{3,}\|\~\{3,}\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock', 'conceal cchar='.s:cchars['codeend']) syn match pandocBlockQuoteinDelimitedCodeBlock '^>' contained containedin=pandocDelimitedCodeBlock syn match pandocCodePre /
.\{-}<\/pre>/ skipnl
 syn match pandocCodePre /.\{-}<\/code>/ skipnl