Commit Graph

13 Commits

Author SHA1 Message Date
Nick Groenen e6fc611b58
fix: find uppercased notes when referenced with lowercase
This commit fixes a bug where, if a note contained uppercase characters
(for example `Note.md`) but was referred to using lowercase
`(`[[note]]`), that note would not be found.
2021-01-10 19:43:28 +01:00
Nick Groenen a0cef3d9c8
New: Add --no-recursive-embeds to break infinite recursion cycles
It's possible to end up with "recursive embeds" when two notes embed
each other. This happens for example when a `Note A.md` contains
`![[Note B]]` but `Note B.md` also contains `![[Note A]]`.

By default, this will trigger an error and display the chain of notes
which caused the recursion.

Using the new `--no-recursive-embeds`, if a note is encountered for a
second time while processing the original note, rather than embedding it
again a link to the note is inserted instead to break the cycle.

See also: https://github.com/zoni/obsidian-export/issues/1
2021-01-05 15:45:34 +01:00
Nick Groenen 4401123ea1
chg: print warnings to stderr rather than stdout
Warning messages emitted when encountering broken links/references will
now be printed to stderr as opposed to stdout.
2021-01-04 21:45:00 +01:00
Nick Groenen 6033407266
new: support links referencing headings
Previously, links referencing a heading (`[[note#heading]]`) would just
link to the file name without including an anchor in the link target.
Now, such references will include an appropriate `#anchor` attribute.

Note that neither the original Markdown specification, nor the more
recent CommonMark standard, specify how anchors should be constructed
for a given heading.

There are also some differences between the various Markdown rendering
implementations.

Obsidian-export uses the [slug] crate to generate anchors which should
be compatible with most implementations, however your mileage may vary.

(For example, GitHub may leave a trailing `-` on anchors when headings
end with a smiley. The slug library, and thus obsidian-export, will
avoid such dangling dashes).

[slug]: https://crates.io/crates/slug
2021-01-04 21:45:00 +01:00
Nick Groenen fcb4cd9dec
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
2021-01-04 19:12:51 +01:00
Nick Groenen ac86d62678
Add brief library documentation to all public types and functions 2020-12-23 00:23:43 +01:00
Nick Groenen 6245c9a31d
Fix: correct relative links within embedded notes
Links within an embedded note would point to other local resources
relative to the filesystem location of the note being embedded.

When a note inside a different directory would embed such a note, these
links would point to invalid locations.

Now these links are calculated relative to the top note, which ensures
these links will point to the right path.
2020-12-22 12:42:07 +01:00
Nick Groenen 207ca1124e
Move vault_contents out of Context and into Exporter
This reduces the need to pass vault_contents around in various places
and restricts Context to dealing with the actual note which is being
processed, instead of also carrying program state information.

This will help with future feature development as note parsing functions
can now access Exporter directly.
2020-12-22 12:01:26 +01:00
Nick Groenen 749f3e425c
Chg: Add extra whitespace around multi-line warnings
This makes errors a bit easier to distinguish after a number of warnings
has been printed.
2020-12-21 13:55:41 +01:00
Nick Groenen 3b46d6b7d1
New: Report file tree when RecursionLimitExceeded is hit
This refactors the Context to maintain a list of all the files which
have been processed so far in a chain of embeds. This information is
then used to print a more helpful error message to users of the CLI when
RecursionLimitExceeded is returned.
2020-12-21 13:54:30 +01:00
Nick Groenen 7027290697
Allow custom filter function to be passed with WalkOptions 2020-12-13 23:15:13 +01:00
Nick Groenen 8a28d627e4
Re-export vault_contents and WalkOptions as pub from crate root 2020-12-11 14:52:59 +01:00
Nick Groenen c2de776148
Public release 2020-12-07 22:35:57 +01:00