1" markdown Text with R statements 2" Language: markdown with R code chunks 3" Last Change: Wed Jul 09, 2014 10:29PM 4" 5" CONFIGURATION: 6" To highlight chunk headers as R code, put in your vimrc: 7" let rmd_syn_hl_chunk = 1 8 9" for portability 10if version < 600 11 syntax clear 12elseif exists("b:current_syntax") 13 finish 14endif 15 16" load all of pandoc info 17runtime syntax/pandoc.vim 18if exists("b:current_syntax") 19 let rmdIsPandoc = 1 20 unlet b:current_syntax 21else 22 let rmdIsPandoc = 0 23 runtime syntax/markdown.vim 24 if exists("b:current_syntax") 25 unlet b:current_syntax 26 endif 27endif 28 29" load all of the r syntax highlighting rules into @R 30syntax include @R syntax/r.vim 31if exists("b:current_syntax") 32 unlet b:current_syntax 33endif 34 35if exists("g:rmd_syn_hl_chunk") 36 " highlight R code inside chunk header 37 syntax match rmdChunkDelim "^[ \t]*```{r" contained 38 syntax match rmdChunkDelim "}$" contained 39else 40 syntax match rmdChunkDelim "^[ \t]*```{r.*}$" contained 41endif 42syntax match rmdChunkDelim "^[ \t]*```$" contained 43syntax region rmdChunk start="^[ \t]*``` *{r.*}$" end="^[ \t]*```$" contains=@R,rmdChunkDelim keepend fold 44 45" also match and syntax highlight in-line R code 46syntax match rmdEndInline "`" contained 47syntax match rmdBeginInline "`r " contained 48syntax region rmdrInline start="`r " end="`" contains=@R,rmdBeginInline,rmdEndInline keepend 49 50" match slidify special marker 51syntax match rmdSlidifySpecial "\*\*\*" 52 53 54if rmdIsPandoc == 0 55 syn match rmdBlockQuote /^\s*>.*\n\(.*\n\@<!\n\)*/ skipnl 56 " LaTeX 57 syntax include @LaTeX syntax/tex.vim 58 if exists("b:current_syntax") 59 unlet b:current_syntax 60 endif 61 " Inline 62 syntax match rmdLaTeXInlDelim "\$" 63 syntax match rmdLaTeXInlDelim "\\\$" 64 syn region texMathZoneX matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroup 65 " Region 66 syntax match rmdLaTeXRegDelim "\$\$" contained 67 syntax match rmdLaTeXRegDelim "\$\$latex$" contained 68 syntax region rmdLaTeXRegion start="^\$\$" skip="\\\$" end="\$\$$" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend 69 syntax region rmdLaTeXRegion2 start="^\\\[" end="\\\]" contains=@LaTeX,rmdLaTeXSt,rmdLaTeXRegDelim keepend 70 hi def link rmdLaTeXSt Statement 71 hi def link rmdLaTeXInlDelim Special 72 hi def link rmdLaTeXRegDelim Special 73endif 74 75setlocal iskeyword=@,48-57,_,. 76 77syn sync match rmdSyncChunk grouphere rmdChunk "^[ \t]*``` *{r" 78 79hi def link rmdChunkDelim Special 80hi def link rmdBeginInline Special 81hi def link rmdEndInline Special 82hi def link rmdBlockQuote Comment 83hi def link rmdSlidifySpecial Special 84 85let b:current_syntax = "rmd" 86 87" vim: ts=8 sw=2 88