Skip to content

Commit

Permalink
Fix highlights nested in directive body
Browse files Browse the repository at this point in the history
The leading two dots of a RST directive gets matched by
rstExplicitMarkup group first, and then the directive name and directive
body will be matched by the groups contained in rstDirectives cluster in
order.

The rstExDirective group in rstDiretives matches any RST directives
other than footnote, citation and hyperlink target, therefore admonition
and code block will be matched by rstExDirective. This fix has
rstExDirective contain rstExplicitMarkup so as to enable recursive RST
directives match.

The interpreted texts enclosed in quotes are not highlighted within a
RST directive body, because the rstCruft cluster contains a non-existing
rstInterpretedText group.It should be renamed to
rstInterpretedTextOrHyperlinkReference which is defined in a
DefineInlineMarkup function call.
  • Loading branch information
madjxatw authored and marshallward committed Feb 12, 2021
1 parent 88a3297 commit 8284ec3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions syntax/rst.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ syn case ignore
syn match rstTransition /^[=`:.'"~^_*+#-]\{4,}\s*$/

syn cluster rstCruft contains=rstEmphasis,rstStrongEmphasis,
\ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
\ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference
\ rstInterpretedTextOrHyperlinkReference,rstInlineLiteral,
\ rstSubstitutionReference, rstInlineInternalTargets,rstFootnoteReference,
\ rstHyperlinkReference

syn region rstLiteralBlock matchgroup=rstDelimiter
\ start='\(^\z(\s*\).*\)\@<=::\n\s*\n' skip='^\s*$' end='^\(\z1\s\+\)\@!'
Expand Down Expand Up @@ -84,7 +85,7 @@ syn region rstHyperlinkTarget matchgroup=rstDirective
execute 'syn region rstExDirective contained matchgroup=rstDirective' .
\ ' start=+' . s:ReferenceName . '::\_s+' .
\ ' skip=+^$+' .
\ ' end=+^\s\@!+ contains=@rstCruft,rstLiteralBlock'
\ ' end=+^\s\@!+ contains=@rstCruft,rstLiteralBlock,rstExplicitMarkup'

execute 'syn match rstSubstitutionDefinition contained' .
\ ' /|.*|\_s\+/ nextgroup=@rstDirectives'
Expand Down

0 comments on commit 8284ec3

Please sign in to comment.