downlit_html_path: Syntax highlight and link an HTML page

View source: R/downlit-html.R

downlit_html_pathR Documentation

Syntax highlight and link an HTML page

Description

  • Code blocks, identified by ⁠<pre>⁠ tags with class ⁠sourceCode r⁠ or any ⁠<pre>⁠ tag inside of ⁠<div class='downlit'>⁠, are processed with highlight().

  • Inline code, identified by ⁠<code>⁠ tags that contain only text (and don't have a header tag (e.g. ⁠<h1>⁠) or ⁠<a>⁠ as an ancestor) are processed processed with autolink().

Use downlit_html_path() to process an .html file on disk; use downlit_html_node() to process an in-memory xml_node as part of a larger pipeline.

Usage

downlit_html_path(in_path, out_path, classes = classes_pandoc())

downlit_html_node(x, classes = classes_pandoc())

Arguments

in_path, out_path

Input and output paths for HTML file

classes

A mapping between token names and CSS class names. Bundled classes_pandoc() and classes_chroma() provide mappings that (roughly) match Pandoc and chroma (used by hugo) classes so you can use existing themes.

x

An xml2::xml_node

Value

downlit_html_path() invisibly returns output_path; downlit_html_node() modifies x in place and returns nothing.

Examples


node <- xml2::read_xml("<p><code>base::t()</code></p>")
node

# node is modified in place
downlit_html_node(node)
node


downlit documentation built on June 22, 2024, 9:17 a.m.