Package 'minidown'

Title: Create Simple Yet Powerful HTML Documents with Light Weight CSS Frameworks
Description: Create minimal, responsive, and style-agnostic HTML documents with the lightweight CSS frameworks such as 'sakura', 'Water.css', and 'spcss'. Powerful features include table of contents floating as a sidebar, folding codes and results, and more.
Authors: Atsushi Yasumoto [aut, cph, cre] , Angelos Chalaris [aut] (mini.css), Susam Pal [aut] (spcss), Mitesh Shah [aut] (sakura), Kognise [aut] (Water.css)
Maintainer: Atsushi Yasumoto <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2024-11-11 03:29:14 UTC
Source: https://github.com/atusy/minidown

Help Index


Generate an HTML widget to download input Rmd file

Description

The button can self-contain the input data by base64 encoding.

Usage

download_rmd_button(
  input = NULL,
  text = "Download Rmd",
  ...,
  class = "button",
  align = "right",
  aside = TRUE,
  embed = NULL
)

Arguments

input

Filename of the input. If NULL, the function automatically detects the name of the knitting Rmd file.

text

The text for the hyperlink.

...

Arguments passed to the embed function.

class

HTML class(es) given to the anchor element generated by embed (default: "button").

align

Align the button by CSS's text-align attribute. This feature is disabled when aside is FALSE

aside

Whether to wrap the anchor element by the aside element.

embed

A function to embed file(s). One of xfun::embed_file, xfun::embed_files, or xfun::embed_dir.

Value

shiny.tag class object.

Examples

set.seed(1L)

input <- tempfile()
writeLines("", input)
download_rmd_button(input)

# Requires zip command
if (interactive()) {
  input <- tempdir()
  download_rmd_button(input, embed = xfun::embed_dir)
}

Lightweight CSS frameworks meta data

Description

To see the names of the frameworks, run names(frameworks). To see the names of themes of a framework, say "mini", run names(frameworks$mini$stylesheet)

Usage

frameworks

Format

A list


Convert to an HTML document powered by the lightweight CSS framework.

Description

The output format is HTML5 in general. If framework = "bootstrap" is given, the output format becomes HTML4 and comparable to rmarkdown::html_document except for the behavior of the code_folding option.

Usage

mini_document(
  framework = "sakura",
  theme = "default",
  toc = FALSE,
  toc_float = FALSE,
  toc_highlight = FALSE,
  section_divs = TRUE,
  code_folding = c("none", "show", "hide"),
  results_folding = c("none", "show", "hide"),
  tabset = FALSE,
  code_download = FALSE,
  self_contained = TRUE,
  math = "katex_serverside",
  template = "default",
  extra_dependencies = NULL,
  includes = list(),
  keep_md = FALSE,
  pandoc_args = NULL,
  ...
)

Arguments

framework, theme

A string to specify the name of a framework (default: "sakura") and its theme (default: "default"). Note that theme = "default" is a special keyword which selects a theme defined as default internally. See frameworks for available light weight CSS frameworks and their themes. If you want to scratch styles by yourself, use framework = "none".

toc

TRUE to include a table of contents in the output

toc_float

TRUE to float the table of contents to the left of the main document content.

toc_highlight

This is an experimental feature. TRUE highlights the table of contents according to the browser's viewport.

section_divs

Wrap sections in <div> tags, and attach identifiers to the enclosing <div> rather than the header itself.

code_folding

Setup code folding by a string or a named list. A choice for the string are "none" to disable, "show" to enable and show all by default), and "hide" to enable and hide all by default. If a named list, each element may have one of the above strings. Names are some of "source", "output", "message", "warning", and "error". If the list does not have some of the element with the above name, they are treated as "none".

results_folding

Setup results folding by a string, "none", "show", or "hide". This feature will fold entire results, including side effects such as figures and tables.

tabset

TRUE converts sections to tabs if they belong to the tabset-class section. The tabs inherit names from the corresponding sections. Unlike rmarkdown::html_document, the tabs can be navigated by table of contents, and can be shared by unique URLs. Note that framework = "bootstrap" falls back to the native feature of rmarkdown::html_document. This feature also requires section_divs = TRUE.

code_download

If TRUE and framework = "bootstrap", the output includes Rmd file itself and supplies download button of it.

self_contained

Produce a standalone HTML file with no external dependencies, using data: URIs to incorporate the contents of linked scripts, stylesheets, images, and videos. Note that even for self contained documents MathJax is still loaded externally (this is necessary because of its size).

math

This is a good choice when you want to exclude JavaScript from the output. The default value "katex" attempts client-side rendreing, but falls back to server-side rendering, i.e. "katex_serverside", when runtime is shiny or shiny_prerendered. Otherwise, if the framework is "bootstrap", this option is passed to the mathjax argument of rmarkdown::html_document.

template

Pandoc template. If "default", the package's internal template is used. If a path, user's original template is used. If NULL, pandoc's internal template is used.

extra_dependencies

Additional function arguments to pass to the base R Markdown HTML output formatter html_document_base

includes

Named list of additional content to include within the document (typically created using the includes function).

keep_md

Keep the markdown file generated by knitting.

pandoc_args

Additional command line options to pass to pandoc

...

Arguments passed to rmarkdown::html_document

Examples

## Not run: 
library(rmarkdown)
library(minidown)
render("input.Rmd", mini_document)

## End(Not run)