R/mindr.R
mm.Rd
Convert between .R, .Rmd, .mm according to the given file names, and create a markmap widget
mm(from = NULL, to = NULL, type = c("file", "text", "dir"), root = NA, show_files = TRUE, remove_curly_bracket = TRUE, bookdown_style = TRUE, widget_name = NA, width = NULL, height = NULL, elementId = NULL, options = markmapOption(preset = "colorful"), method = c("regexpr", "pandoc"))
from | character. The path of the input file, or the input markdown text, or the path to the directory. Dependent on 'type'. |
---|---|
to | character. The path of the output file. |
type | character. The type of the input. If type == 'dir' and the OS is LinUx, the 'tree' command must be pre-installed: |
root | character. a string displayed as the root of the mind map |
show_files | logical. Whether to show files in a directory. Only valid when type == 'dir'. |
remove_curly_bracket | logical. Whether to remove #ID in the headers of the markdown file (usually in a 'bookdown' https://github.com/rstudio/bookdown project). |
bookdown_style | logical. whether the markdown files are in bookdown style, i.e. index.Rmd at the beginning, |
widget_name | The file name of the html widget to save. |
width | the width of the markmap |
height | the height of the markmap |
elementId | character. |
options | the markmap options |
method | "regexpr" uses regular expressions, 'pandoc' uses pandoc to find the headings. |
A HTML widget object rendered from a given document.
For LinUx OS and mac OS, the 'tree' command must be pre-installed before using 'show_files = FALSE'.
Linux: sudo apt-get install tree
mac: install Homebrew first. Then in the terminal: brew install tree
.
# NOT RUN { ### text -> widget input <- c("# Chapter 1", "## Section 1.1", "## Section 1.2", "# Chapter 2") mm(from = input, type = "text", root = "mindr") ### directory -> widget input <- paste0(.libPaths(), "/mindr")[1] mm(from = input, type = "dir") mm(from = input, type = "dir", widget_name = "mindrtest.html") ### directory -> mm mm(from = input, type = "dir", to = "test.mm") ### directory -> md mm(from = input, type = "dir", to = "test.md") ### directory -> txt mm(from = input, type = "dir", to = "test.txt") ### Rmd -> widget input <- system.file("examples/r/rmd2r.Rmd", package = "mindr") mm(from = input, type = "file", root = "mindr") ### Rmd -> r mm(from = input, type = "file", root = "mindr", to = "test.r") ### Rmd -> mm mm(from = input, type = "file", root = "mindr", to = "test.mm") ### mm -> widget input <- system.file("examples/mm/bookdownplus.mm", package = "mindr") mm(from = input, type = "file", root = "mindr") ### mm -> Rmd mm(from = input, type = "file", root = "mindr", to = "test.Rmd") ### mm -> r mm(from = input, type = "file", root = "mindr", to = "test.r") ### r -> widget input <- system.file("examples/r/r2rmd.R", package = "mindr") mm(from = input, type = "file", root = "mindr") ### r -> Rmd mm(from = input, type = "file", root = "mindr", to = "test.Rmd") ### r -> mm mm(from = input, type = "file", root = "mindr", to = "test.mm") ### The outline of the book Learning R input <- system.file("examples/xuer/xuer.md", package = "mindr") mm(from = input, type = "file", root = "Learning R", to = "learningr.mm") # }