guidedoc_defaults¶
The built-in pieces Guidedog assembles around the engine: the registry of readers and renderers (registry), typed read options for the built-in readers (rst_options, sphinx_options, myst_options), and the highlighters that connect gd-highlight to the renderers (HtmlHighlighter, TypstHighlighter).
let registry = guidedoc_defaults::registry();
let mut ws = guidedoc::Workspace::new();
let html = guidedoc::convert_text(&mut ws, ®istry, "myst", "html", "# Hello\n");
assert!(html.expect("converts").contains("Hello"));
Structs
- pub struct guidedoc_defaults::HtmlHighlighter¶
-
Highlights code blocks as the HTML Pygments writes for Sphinx, with its short CSS classes.
The language resolves as Sphinx resolves it:
defaultis Python (or a Python console session), falling back to plain text when the code does not lex as Python;guessguesses; an unknown language is plain text, escaped as Pygments escapes it.One value keeps a reusable buffer, so a renderer that highlights many blocks does not allocate per block. It is not
Sync: give each rendering thread its own.Implementations
- impl HtmlHighlighter
-
- pub fn new() -> HtmlHighlighter¶
-
Creates a highlighter with an empty buffer.
Trait Implementations
- impl Highlighter for HtmlHighlighter
-
- fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool
- pub struct guidedoc_defaults::TypstHighlighter¶
-
Highlights code blocks as Typst data for the book template’s
gd-highlightfunction, so books draw code with Guidedog’s colours rather than Typst’s.It declines (returns
false) plain text and languages it does not know, so the renderer keeps Typst’s own raw block for those. LikeHtmlHighlighter, one value reuses its buffer and belongs to one thread.Implementations
- impl TypstHighlighter
-
- pub fn new() -> TypstHighlighter¶
-
Creates a highlighter with an empty buffer.
Trait Implementations
- impl Highlighter for TypstHighlighter
-
- fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool
- pub struct guidedoc_defaults::ReaderSettings¶
-
The settings of the built-in readers for converting one file, kept together so read options can borrow them: Docutils” settings for
rst, Sphinx’s forsphinx, and MyST with the Sphinx layer’s directives and roles formyst.Fields
- pub rst: guidedoc_rst::Settings¶
-
The
rstreader’s settings.
- pub sphinx: guidedoc_sphinx::Config¶
-
The
sphinxreader’s configuration.
- pub myst: guidedoc_commonmark::Settings¶
-
The
mystreader’s settings, with the Sphinx layer as their extension.
Implementations
- impl ReaderSettings
-
- pub fn with_config(config: guidedoc_sphinx::Config) -> Self¶
-
Settings whose Sphinx layer (for
sphinxandmyst) usesconfig.
- pub fn for_source() -> Self¶
-
Settings for writing source again (the
rstrenderer): no smart quotes, so the text keeps the quotes and dashes it was written with.
- pub fn options(&self, reader: &str) -> ReadOptions<'_>¶
-
The read options for reader
reader, borrowing these settings; other readers (commonmark) get the defaults.
Trait Implementations
- impl Default for ReaderSettings
-
- fn default() -> Self
-
The readers” defaults; MyST reads
{doc},{ref}and directives as Sphinx does.
Functions
- pub fn guidedoc_defaults::myst_options(settings: &guidedoc_commonmark::Settings) -> ReadOptions<'_>¶
-
Read options for the
mystreader withsettings(fromguidedoc_commonmark::Settings::default()orguidedoc_sphinx::myst_settings); the options borrow the settings. Thecommonmarkreader takes no settings.
- pub fn guidedoc_defaults::registry() -> Registry¶
-
The built-in registry: readers
rst,sphinx,commonmark(pure CommonMark 0.31.2) andmyst(MyST Markdown); renderershtml,typst(Typst source),text, andrst(reStructuredText).Building it allocates two small vectors; keep one per program or thread and reuse it.
- pub fn guidedoc_defaults::rst_options(settings: &guidedoc_rst::Settings) -> ReadOptions<'_>¶
-
Read options for the
rstreader withsettings(start fromguidedoc_rst::default_settings()); the options borrow the settings.Settings travel with their type, so another reader refuses them with
core.read.settings_typeinstead of misreading them.
- pub fn guidedoc_defaults::sphinx_options(config: &guidedoc_sphinx::Config) -> ReadOptions<'_>¶
-
Read options for the
sphinxreader withconfig(start fromguidedoc_sphinx::Config::default()); the options borrow the configuration.