Skip to main content

Crate docs_pipeline

Crate docs_pipeline 

Source
Expand description

§docs-pipeline

Markdown rendering and syntax highlighting pipeline for documentation sites, extracted from the Tachyon knowledge base renderer.

§Modules

  • markdown — markdown → HTML/plain-text/AST rendering with GFM, wikilinks, admonitions, embeds, block references, TOC extraction, and ammonia-based sanitization.
  • syntax — tree-sitter based syntax highlighting with per-language cargo features (lang-rust, lang-python, …), themeable CSS output, and rendered-HTML code block highlighting.
  • latex — KaTeX equation rendering with $/$$ placeholder handling that skips <pre>/<code> content.
  • embeds — whitelisted rich-media embed rendering (YouTube, Figma, Gist, CodePen, tweets) as sandboxed iframes.
  • sanitize — standalone HTML sanitization.
  • types — render options, output formats, results, metadata, themes, and supported languages.
  • error — the pipeline error type.

§Example

use docs_pipeline::{render_markdown, extract_toc};

let md = "# Getting Started\n\nSome **bold** text.";
let html = render_markdown(md);
assert!(html.contains("<strong>bold</strong>"));

let toc = extract_toc(md);
assert_eq!(toc.len(), 1);
assert_eq!(toc[0].text, "Getting Started");

§Syntax highlighting example

use docs_pipeline::syntax::SyntaxHighlighter;

let hl = SyntaxHighlighter::new();
assert!(hl.is_language_supported("rust"));
let html = hl.highlight_or_fallback("fn main() {}", "rust");
assert!(html.contains("syntax-highlight"));

Re-exports§

pub use embeds::count_embeds;
pub use embeds::embed_csp_policy;
pub use embeds::is_domain_whitelisted;
pub use embeds::render_embed;
pub use error::Error;
pub use error::Result;
pub use latex::LatexDocumentRenderer;
pub use latex::LatexRenderer;
pub use markdown::extract_inline_toc;
pub use markdown::extract_toc;
pub use markdown::extract_toc_from_html;
pub use markdown::render_markdown;
pub use markdown::strip_html_tags;
pub use markdown::try_render_markdown;
pub use markdown::BlockReference;
pub use markdown::EmbedBlock;
pub use markdown::HtmlTocEntry;
pub use markdown::MarkdownParser;
pub use markdown::TocEntry;
pub use sanitize::sanitize_html;
pub use syntax::highlight_code_blocks;
pub use syntax::SyntaxHighlighter;
pub use types::Language;
pub use types::MarkdownOptions;
pub use types::OutputFormat;
pub use types::RenderMetadata;
pub use types::RenderOptions;
pub use types::RenderResult;
pub use types::RenderStats;
pub use types::SyntaxTheme;

Modules§

embeds
Rich-media embed rendering.
error
Error types for the docs pipeline.
latex
LaTeX rendering with KaTeX.
markdown
Markdown parsing and rendering.
sanitize
HTML sanitization.
syntax
Syntax highlighting with tree-sitter.
types
Shared types for the docs pipeline.