rich-iannone / DiagrammeR

Graph and network visualization using tabular data in R
https://rich-iannone.github.io/DiagrammeR/
Other
1.69k stars 247 forks source link

[Request] knitr engine #350

Open artemklevtsov opened 5 years ago

artemklevtsov commented 5 years ago

Hi,

Thanks for the package.

It would be nice to add knit engine to write code in the chunk directly. Like it implemented in the https://github.com/javierluraschi/nomnoml/

RichardJActon commented 5 years ago

The lack of syntax highlighting in Rnotebook chunks resulting from having to have the graph specification in a string is really quite inconvenient. It really breaks the flow to have to make the graph in a separate .gv file to get the syntax highlighting then paste back into an Rnotebook chunk. This feature would be a massive quality of life improvement.

retorquere commented 4 years ago

This should get you in the right direction (although knits don't display for me):

knitr::knit_engines$set(mermaid = function(options) {
  code <- paste(options$code, collapse = "\n")
  if (options$eval) mermaid(code) else code
})