rstudio / blogdown

Create Blogs and Websites with R Markdown
https://pkgs.rstudio.com/blogdown/
1.74k stars 331 forks source link

emoji in Rmarkdown #171

Closed nancym closed 7 years ago

nancym commented 7 years ago

If I put this in config.toml:

enableEmoji = true

An emoji like :smile: in a markdown file will be rendered as :smile: in the HTML output. Is there anything I can put in _output.yml to get emoji to work in an Rmarkdown file, e.g. something like this:

blogdown::html_page:
  md_extensions: +emoji

Thanks!

yihui commented 7 years ago

No, not to my knowledge. However, if you are okay with Blackfriday's Markdown, you will be able to render R Markdown to Markdown instead of HTML after I implement #165. Then emoji will work.

yihui commented 7 years ago

165 has been implemented. Please see the documentation about .Rmarkdown files at https://bookdown.org/yihui/blogdown/output-format.html

ProQuestionAsker commented 7 years ago

Just for clarification, does this mean that emojis can't be rendered in either .Rmd or .Rmarkdown files if the output is like this?

output:
    blogdown::html_page:
        toc:true

And the workaround is to render the output like this

output:
    md_document:
        toc:true

Or to write in a .md document instead of .Rmd or .Rmarkdown?

yihui commented 7 years ago

@ProQuestionAsker The life cycles of .Rmd vs .Rmarkdown:

Emoji is a Markdown extension only in Blackfriday. Pandoc does not support it. As a result, you must use .Rmarkdown if you must have emojis.

For TOC in .Rmarkdown, you have to use the Hugo variable .TableOfContents: https://bookdown.org/yihui/blogdown/templates.html#how-to

This won't work in blogdown:

output:
    md_document:
        toc:true

blogdown only supports the output format blogdown::html_page. All other output formats are ignored.

ProQuestionAsker commented 7 years ago

Ah, that makes sense. Thank you!!

andry-tino commented 5 years ago

@yihui: Is there a way to extend the generation pipeline so that I can process the generated HTML and enable emojis? It is such a shame that we cannot use Hugo features with .Rmd files as I need all the features there plus Hugo :(

aosmith16 commented 5 years ago

@andry-tino I may be missing what you are asking for, but you can put emojis in .Rmd files via the emo package.

The code would look something like `r emo::ji("grinning")`, which you can add directly within the plain text of a post.