Title: | 'R Markdown' Format for Scientific and Technical Writing |
---|---|
Description: | Scientific and technical article format for the web. 'Distill' articles feature attractive, reader-friendly typography, flexible layout options for visualizations, and full support for footnotes and citations. |
Authors: | Christophe Dervieux [aut, cre] , JJ Allaire [aut] , Rich Iannone [aut], Alison Presmanes Hill [aut] , Yihui Xie [aut] , Posit Software, PBC [cph, fnd], Google LLC [ctb, cph] (https://distill.pub/guide/), Nick Williams [ctb, cph] (https://wicky.nillia.ms/headroom.js/), Denis Demchenko [ctb, cph] (https://github.com/lancedikson/bowser), The Polymer Authors [ctb, cph] (https://www.webcomponents.org/polyfills/), Gábor Csárdi [ctb, cph] (whoami), JooYoung Seo [ctb] |
Maintainer: | Christophe Dervieux <[email protected]> |
License: | Apache License 2.0 |
Version: | 1.6.1 |
Built: | 2024-11-16 04:35:25 UTC |
Source: | https://github.com/rstudio/distill |
Create (and optionally edit) a new distill article.
create_article( file, template = "distill_article", package = "distill", create_dir = FALSE, edit = TRUE )
create_article( file, template = "distill_article", package = "distill", create_dir = FALSE, edit = TRUE )
file |
File name for the draft |
template |
Template to use as the basis for the draft. This is either
the full path to a template directory or the name of a template directory
within the |
package |
(Optional) Name of package where the template is located. |
create_dir |
|
edit |
|
Create a new blog post
create_post( title, collection = "posts", author = "auto", slug = "auto", date = Sys.Date(), date_prefix = date, draft = FALSE, edit = interactive() )
create_post( title, collection = "posts", author = "auto", slug = "auto", date = Sys.Date(), date_prefix = date, draft = FALSE, edit = interactive() )
title |
Post title |
collection |
Collection to create the post within (defaults to "posts") |
author |
Post author. Automatically drawn from previous post if not provided. |
slug |
Post slug (directory name). Automatically computed from title if not provided. |
date |
Post date (defaults to current date) |
date_prefix |
Date prefix for post slug (preserves chronological order for posts
within the filesystem). Pass |
draft |
Mark the post as a |
edit |
Open the post in an editor after creating it. |
This function must be called from with a working directory that is within a Distill website.
## Not run: library(distill) create_post("My Post") ## End(Not run)
## Not run: library(distill) create_post("My Post") ## End(Not run)
Create a theme CSS file and write it to the current working directory
create_theme(name = "theme", edit = TRUE)
create_theme(name = "theme", edit = TRUE)
name |
Name of theme file (will be written as name.css) |
edit |
Open an editor for the theme file |
How do you apply a custom theme to a Distill site or blog? You have two options:
Apply it site-wide by adding a theme
key to the top-level of your
_site.yml
configuration file:
name: "distill" title: "Distill for R Markdown" theme: theme.css navbar: # (navbar definition here)
Apply to an individual article by adding a theme
key to your
article’s YAML front-matter:
--- title: "The Sharpe Ratio" output: distill::distill_article: toc: true theme: theme.css ---
The second option allows for you to apply your theme to individual articles, while using a different theme for the rest of your site. Note that this is only possible for stand-alone articles within a website — you cannot apply a theme to individual blog posts only.
For further details about theming refer to the online documentation.
Create a basic skeleton for a Distill website or blog. Use the create_website()
function for a website and the create_blog()
function for a blog.
create_website(dir, title, gh_pages = FALSE, edit = interactive()) create_blog(dir, title, gh_pages = FALSE, edit = interactive())
create_website(dir, title, gh_pages = FALSE, edit = interactive()) create_blog(dir, title, gh_pages = FALSE, edit = interactive())
dir |
Directory for website |
title |
Title of website |
gh_pages |
Configure the site for publishing using GitHub Pages |
edit |
Open site index file or welcome post in an editor. |
The dir
and title
parameters are required (they will be prompted for
interactively if they are not specified).
## Not run: library(distill) create_website("mysite", "My Site") ## End(Not run)
## Not run: library(distill) create_website("mysite", "My Site") ## End(Not run)
Scientific and technical writing, native to the web.
distill_article( toc = FALSE, toc_depth = 3, toc_float = TRUE, fig_width = 6.5, fig_height = 4, fig_retina = 2, fig_caption = TRUE, dev = "png", smart = TRUE, code_folding = FALSE, self_contained = TRUE, highlight = "default", highlight_downlit = TRUE, mathjax = "default", extra_dependencies = NULL, theme = NULL, css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, ... )
distill_article( toc = FALSE, toc_depth = 3, toc_float = TRUE, fig_width = 6.5, fig_height = 4, fig_retina = 2, fig_caption = TRUE, dev = "png", smart = TRUE, code_folding = FALSE, self_contained = TRUE, highlight = "default", highlight_downlit = TRUE, mathjax = "default", extra_dependencies = NULL, theme = NULL, css = NULL, includes = NULL, keep_md = FALSE, lib_dir = NULL, md_extensions = NULL, pandoc_args = NULL, ... )
toc |
|
toc_depth |
Depth of headers to include in table of contents |
toc_float |
Float the table of contents to the left when the article
is displayed at widths > 1000px. If set to |
fig_width |
Default width (in inches) for figures |
fig_height |
Default height (in inches) for figures |
fig_retina |
Scaling to perform for retina displays (defaults to 2, which
currently works for all widely used retina displays). Set to |
fig_caption |
|
dev |
Graphics device to use for figure output (defaults to png) |
smart |
Produce typographically correct output, converting straight
quotes to curly quotes, |
code_folding |
Include code blocks hidden, and allow users to
optionally display the code by clicking a "Show code" button just above
the output. Pass a character vector to customize the text of the
"Show code" button. You can also specify |
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). |
highlight |
Syntax highlighting style. Supported styles include "default", "rstudio", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", "breezedark", and "haddock". Pass NULL to prevent syntax highlighting. |
highlight_downlit |
Use the downlit package to highlight R code (including providing hyperlinks to function documentation). |
mathjax |
Include mathjax. The "default" option uses an https URL from a
MathJax CDN. The "local" option uses a local version of MathJax (which is
copied into the output directory). You can pass an alternate URL or pass
|
extra_dependencies |
Extra dependencies as a list of the
|
theme |
CSS file with theme variable definitions |
css |
CSS and/or Sass files to include. Files with an extension of |
includes |
Named list of additional content to include within the
document (typically created using the |
keep_md |
Keep the markdown file generated by knitting. |
lib_dir |
Directory to copy dependent HTML libraries (e.g. jquery,
bootstrap, etc.) into. By default this will be the name of the document with
|
md_extensions |
Markdown extensions to be added or removed from the
default definition of R Markdown. See the |
pandoc_args |
Additional command line options to pass to pandoc |
... |
Additional function arguments to pass to the base R Markdown HTML
output formatter |
Distill articles feature attractive, reader-friendly typography, flexible layout options for visualizations, and full support for footnotes and citations.
R Markdown site generator for Distill websites
distill_website(input, encoding = getOption("encoding"), ...)
distill_website(input, encoding = getOption("encoding"), ...)
input |
Website directory (or the name of a file within the directory). |
encoding |
Ignored. The encoding is always assumed to be UTF-8. |
... |
Currently unused. |
Import a distill post from an external source (e.g. GitHub repo, RPubs article, etc.).
Importable posts must have distill::distill_article
as the output format in the YAML.
import_post( url, slug = "auto", date = Sys.Date(), date_prefix = date, check_license = TRUE, overwrite = FALSE, view = interactive() ) update_post(slug, view = interactive())
import_post( url, slug = "auto", date = Sys.Date(), date_prefix = date, check_license = TRUE, overwrite = FALSE, view = interactive() ) update_post(slug, view = interactive())
url |
URL for distill post to import |
slug |
Post slug (directory name). Automatically computed from title if not provided. |
date |
Post date (defaults to current date) |
date_prefix |
Date prefix for post slug (preserves chronological order for posts
within the filesystem). Pass |
check_license |
Verify that the imported posted has a creative commons license |
overwrite |
Overwrite existing post? (defaults to |
view |
View the post after importing it. |
Returns (invisibly) a logical indicating whether the operation completed (it may not complete if, for example, the user chose not to import an article that lacked a creative commons license).
Publish a website to RStudio Connect
publish_website( site_dir = ".", site_name = NULL, method = c("rsconnect"), server = NULL, account = NULL, render = TRUE, launch_browser = interactive() )
publish_website( site_dir = ".", site_name = NULL, method = c("rsconnect"), server = NULL, account = NULL, render = TRUE, launch_browser = interactive() )
site_dir |
Directory containing website. Defaults to current working directory. |
site_name |
Name for the site (names must be unique within an account). Defaults
to the |
method |
Publishing method (currently only "rsconnect" is available) |
account , server
|
Uniquely identify a remote server with either your
user Use |
render |
|
launch_browser |
If |
## Not run: library(distill) publish_website() ## End(Not run)
## Not run: library(distill) publish_website() ## End(Not run)
Rename a blog post directory, by default using the title and date specified within the post's front matter.
rename_post_dir(post_dir, slug = "auto", date_prefix = "auto")
rename_post_dir(post_dir, slug = "auto", date_prefix = "auto")
post_dir |
Path to post directory |
slug |
Post slug (directory name). Automatically computed from title if not provided. |
date_prefix |
Date prefix for post. Defaults to the post's date
field (or the current date if there is none). Pass |
This function must be called from with a working directory that is within a Distill website.
## Not run: library(distill) rename_post_dir("_posts/2020-09-12-my-post") rename_post_dir("_posts/2020-09-12-my-post", date_prefix = "9/15/2020") ## End(Not run)
## Not run: library(distill) rename_post_dir("_posts/2020-09-12-my-post") rename_post_dir("_posts/2020-09-12-my-post", date_prefix = "9/15/2020") ## End(Not run)