Skip to main content

patch_markdown

Function patch_markdown 

Source
pub fn patch_markdown(old: &str, new: &str, options: &PatchOptions) -> Patch
Expand description

Diffs two Markdown documents (old, new) as a single Patch whose changes are attributed to the PatchOptions::owner. Each hunk lives at the line its paragraph starts on in the document itself.

Backs jubarte diff old.md new.md (--format critic, or the unified patch --format/patch when both inputs are Markdown).

use jubarte_edit::markdown::{Attribution, PatchOptions, patch_markdown};

let options = PatchOptions {
    old_name: "a.md".into(),
    new_name: "b.md".into(),
    owner: Attribution { author: "Ana".into(), date: "2026-09-30T14:05:00Z".into() },
};
let patch = patch_markdown("Due in 30 days.\n", "Due in 45 days.\n", &options);
assert_eq!(
    patch.to_string(),
    "--- a/a.md\n+++ b/b.md\tAna\t2026-09-30T14:05:00Z\n@@ [line:1] @@\nDue in [-30-]{+45+} days.\n"
);