Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

knitr Markdown highlighting in Emacs?

Is there any modification of an existing tool or new tool that will syntax-highlight (colour) blocks of R code in a knitr markdown document when opened in Emacs?

The knitr chunks I am looking at are triple-backtick blocks [```] that contain R code inside.

EDIT: things that I tried so far:

- Ubuntu 12.04 with Emacs 23

emacs --version GNU Emacs 23.3.1 

1. Polymode

https://github.com/vitoshka/polymode/issues/3

I am trying to get polymode to syntax-highlight my Rmd files, but it's complaining about a 'color' load file:

cd ~/.emacs.d git clone https://github.com/vitoshka/polymode.git 

In my .emacs file:

(add-to-list 'load-path "/home/avilella/.emacs.d/polymode/") (add-to-list 'load-path "/home/avilella/.emacs.d/polymode/modes/")  ;; Require any polymode bundles that you are interested in:  (require 'poly-R) (require 'poly-markdown) 

eval-buffer:

Cannot open load file: color 

- CentOS with Emacs 24:

emacs --version GNU Emacs 24.2.1 

1. Polymode installed correctly

Open a Rmd file, M-x polymode-minor-mode, no change to the syntax highlighting.


emacs --version GNU Emacs 24.3.1 

1. Polymode installed correctly

Open a Rmd file, M-x poly-markdown+r-mode, some of the syntax highlighting starts to appear, but I need to manually modify the test in each triple-tick block of code for it to fully show the syntax.

Enter image description here

Enter image description here

The second image is just after typing a Return before the knitr block.

like image 228
719016 Avatar asked May 15 '13 14:05

719016


1 Answers

This might help: http://sjp.co.nz/posts/emacs-ess-knitr/

Knitr markdown in Emacs through ESS

like image 117
priyolahiri Avatar answered Sep 29 '22 00:09

priyolahiri