jubarte-markdown 0.20.0

Markdown in and out of Word documents for the jubarte engine: CriticMarkup as tracked changes, the agent view, and .doc reading
Documentation

jubarte-markdown

crates.io docs.rs CI license docs

Markdown in and out of Word documents for the jubarte DOCX engine. It writes CommonMark (with GitHub's tables, strikethrough, task lists and footnotes) as a .docx, turning CriticMarkup into Word tracked changes and comments; it reads a .docx back as the agent view's Markdown; it diffs two texts as CriticMarkup; and it reads Word 97-2003 .doc files.

Where it sits

jubarte-dom → jubarte-opc → jubarte-redlines / jubarte-render → jubarte-doc / jubarte-markdown / jubarte-edit → jubarte-cli → jubarte

jubarte-markdown sits on jubarte-dom, jubarte-opc, jubarte-redlines and jubarte-doc, and on jubarte-render behind its render feature. jubarte-edit builds on it and adds the patch, redline and unified views to its markdown module.

When to use this crate

Depend on jubarte-markdown to generate Word documents from Markdown, to read documents as Markdown for a model or a diff, or to read .doc files. For Markdown patches applied as tracked changes, depend on jubarte-edit; for everything, on the facade crate jubarte.

Install

cargo add jubarte-markdown@0.20.0

or in Cargo.toml:

[dependencies]
jubarte-markdown = "0.20.0"

The jubarte crates are released together at one version and pin each other exactly, so depend on the same version of every jubarte crate you use. Minimum supported Rust version: 1.94.

Cargo features

None is on by default.

Feature What it adds
render Page-aware reading through jubarte-render (and jubarte-doc/render): page_texts, with_page_markers, and page markers taken from the layout. Without it, page markers come from the document's explicit breaks.
test-support Hidden helpers for jubarte's own tests; not a public API.

Example

use jubarte_markdown::changes::list_changes;
use jubarte_markdown::markdown::{DocxOptions, diff_markdown, markdown_to_docx};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // CriticMarkup becomes Word tracked changes.
    let options = DocxOptions { author: "Reviewer".into(), ..DocxOptions::default() };
    let written = markdown_to_docx("The term is {--two--}{++three++} years.\n", &options)?;
    assert!(!list_changes(&written.docx)?.is_empty());

    // Two Markdown texts diffed as CriticMarkup.
    let diff = diff_markdown("The term is two years.\n", "The term is three years.\n");
    assert!(diff.contains("three"));
    Ok(())
}

Modules

  • markdown: Markdown to DOCX (markdown_to_docx, DocxOptions), DOCX to Markdown (docx_to_markdown, MarkdownOptions), and diff_markdown.
  • legacy_doc: Word 97-2003 .doc to text, paragraphs, headings, lists and tables (the main story).
  • Re-exported from the layers below: changes, comments, validate, inspect and debug (jubarte-doc); comparer and document_comparer (jubarte-redlines); opc, admission, settings and strict_translation (jubarte-opc); xmllinq, namespaces, ids and util (jubarte-dom).

License

Apache-2.0. NOTICE carries the attributions of the projects this code derives from.

Links