From fcb4cd9dec61e51616a046da5476752592bd4d6f Mon Sep 17 00:00:00 2001 From: Nick Groenen Date: Mon, 4 Jan 2021 19:12:51 +0100 Subject: [PATCH] new: support embeds referencing headings Previously, partial embeds (`![[note#heading]]`) would always include the entire file into the source note. Now, such embeds will only include the contents of the referenced heading (and any subheadings). Links and embeds of [arbitrary blocks] remains unsupported at this time. [arbitrary blocks]: https://publish.obsidian.md/help/How+to/Link+to+blocks --- src/lib.rs | 189 ++++++++++++------ .../main-samples/embeds-partial-note.md | 9 + .../input/main-samples/embeds-partial-note.md | 1 + .../input/main-samples/note-with-headings.md | 22 ++ 4 files changed, 165 insertions(+), 56 deletions(-) create mode 100644 tests/testdata/expected/main-samples/embeds-partial-note.md create mode 100644 tests/testdata/input/main-samples/embeds-partial-note.md create mode 100644 tests/testdata/input/main-samples/note-with-headings.md diff --git a/src/lib.rs b/src/lib.rs index b415dd6..8bf2202 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,7 @@ type MarkdownTree<'a> = Vec>; lazy_static! { static ref OBSIDIAN_NOTE_LINK_RE: Regex = - Regex::new(r"^(?P[^#|]+)(#(?P.+?))??(\|(?P