Skip to content

Commit

Permalink
Clarified process for working with non-ASCII characters (thanks @mmar…
Browse files Browse the repository at this point in the history
…ascio!). Fixes #17
  • Loading branch information
andrewheiss committed Jul 2, 2014
1 parent dd06ddc commit 4231ba8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sublime knitr

* Version: 1.2.0
* Date: July 1, 2014
* Version: 1.2.1
* Date: July 2, 2014

This package provides [**knitr**](http://yihui.name/knitr/) Markdown and LaTeX support in Sublime Text 2 and 3. It comes with:

Expand Down Expand Up @@ -40,6 +40,15 @@ Alternatively, you can force the build system to open the resulting `.md` file i
"cmd": [ "Rscript -e \"library(knitr); knit('$file_name')\"; open $file_base_name.md" ],


## Unicode and other encoding issues

Working with non-ASCII characters in plots is a little tricky because of how LaTeX and R differently support Unicode. Here's are some general guidelines for fixing character encoding issues:

1. Add `LANG=en_US.UTF-8` to `~/.Renviron` (create this file if needed). This will ensure that R runs with Unicode support whenver it opens.
2. Add a separate chunk near the beginning of your document with this: `pdf.options(encoding = '<encoding>')`, where `encoding` is any of those listed in the output of this command: `list.files(system.file('enc', package = 'grDevices'))`. Choose an encoding that encompasses all the characters you're using in your plots.
3. If using `.Rnw` and LaTeX, ensure that `\usepackage[utf8]{inputenc}` is in your preamble.


## Roadmap and wish list

* Better Markdown syntax highlighting, including Multimarkdown and Pandoc extras like footnotes, tables, and citations.
Expand Down
2 changes: 1 addition & 1 deletion knitr-Markdown.sublime-build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"selector": "text.html.markdown.knitr",
"working_dir": "${project_path:${folder}}",
"env": { "LANG": "en_US.UTF-8" },
"cmd": [ "Rscript -e \"library(knitr); knit('$file', output='$file_path/$file_base_name.md')\"" ],
"shell": true,

Expand All @@ -9,7 +10,6 @@
{
"name": "Run",
"working_dir": "$file_path",
"env": { "LANG": "en_US.UTF-8" },
"shell_cmd": "Rscript -e \"rmarkdown::render(input = '$file')\""
}
]
Expand Down

0 comments on commit 4231ba8

Please sign in to comment.