First, put this bundle in your TextMate bundle directory:
# Textmate2
mkdir -p ~/Library/Application\ Support/Avian/Bundles/
cd ~/Library/Application\ Support/Avian/Bundles/
git clone https://github.com/streeter/markdown-redcarpet.tmbundle.git
# Then, make sure you've got `redcarpet` and `pygments.rb`
# installed with your gem library with system's Ruby 1.8:
unset GEM_HOME
unset GEM_PATH
sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install redcarpet -v 2.3.0
sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install pygments.rb
The following syntaxes will be highlighted inside the fenced block:
Bonus Install the Scott Web Theme from Preferences → Bundles for a nice looking preview
Reload TextMate and tell it to read .md
files as Markdown Redcarpet types.
For more information about GitHub's Redcarpet markdown, checkout this post.
This bundle also supports R Markdown files (Rmd, rmd) by properly scoping fenced R code chunks and inline R code to the R source syntax when used with the R TextMate bundle. You can then use the commands from the R TextMate bundle to evaluate R code, send it to the R GUI, etc. This bundle includes two commands to knit R Markdown files and produce the HTML result: one uses the knitr package while the other one (recommended, see why here) uses the knitrBootstrap package.
For R noweb files (Rnw, rnw) you might be interested in the knitr TextMate bundle which bridges LaTeX and R code.