Commit Graph

17 Commits

Author SHA1 Message Date
Nick Groenen 151679788a
Fix: trim filenames while resolving wikilinks
Obsidian trims the filename part in a [[WikiLink|label]], so each of
these are equivalent:

[[wikilink]]
[[ wikilink ]]
[[ wikilink |wikilink]]

Obsidian-export now behaves similarly.

Fixes #188
2023-12-02 12:19:16 +01:00
Martin Heuschober 018c9606a6
Implement frontmatter based filtering (#163)
This allows limiting the notes that will be exported using `--skip-tags` and `--only-tags`

---------

Co-authored-by: Martin Heuschober <martin.heuschober@posteo.net>
Co-authored-by: Nick Groenen <nick@groenen.me>
Co-authored-by: Martin Heuschober <martin_heuschober@trimble.com>
2023-12-02 11:29:29 +01:00
Nick Groenen 3d98d65403
Add additional common pre-commit-hooks
I have these hooks enabled on many of my projects, but for some reason
forgot them here which led to the issue described in
https://github.com/zoni/obsidian-export/pull/181

This should help prevent that from happening again.
2023-09-26 08:48:06 +02:00
Nick Groenen 84308c9f1f
New: support Obsidian's "Strict line breaks" setting
This change introduces a new `--hard-linebreaks` CLI argument. When
used, this converts soft line breaks to hard line breaks, mimicking
Obsidian's "Strict line breaks" setting.

Implementation detail: I considered naming this flag
`--strict-line-breaks` to be consistent with Obsidian itself, however I
feel the name is somewhat misleading and ill-chosen.
2022-01-02 00:42:51 +01:00
Narayan Sainaney c4bc77402e
Chg: Treat SVG files as embeddable images
This will ensure SVG files are included as an image when using `![[foo.svg]]` syntax, as opposed to only being linked to.
2021-09-24 11:12:27 +02:00
Nick Groenen 8dc7e59a79
New: support postprocessors running on embedded notes
This introduces support for postprocessors that are run on the result of
a note that is being embedded into another note. This differs from the
existing postprocessors (which remain unchanged) that run once all
embeds have been processed and merged with the final note.

These "embed postprocessors" may be set through the new
`Exporter::add_embed_postprocessor` method.
2021-09-12 14:53:27 +02:00
Nick Groenen 634b0d70ac
New: add start_at option to export a partial vault
This introduces a new `--start-at` CLI argument and corresponding
`start_at()` method on the Exporter type that allows exporting of only a
given subdirectory within a vault.

See the updated README file for more details on when and how this may be
used.
2021-08-27 16:03:54 +02:00
Nick Groenen 58eb79e53d
new: postprocessing support
Add support for postprocessing of Markdown prior to writing converted
notes to disk.

Postprocessors may be used when making use of Obsidian export as a Rust
library to do the following:

1. Modify a note's `Context`, for example to change the destination
   filename or update its Frontmatter.
2. Change a note's contents by altering `MarkdownEvents`.
3. Prevent later postprocessors from running or cause a note to be
   skipped entirely.

Future releases of Obsidian export may come with built-in postprocessors
for users of the command-line tool to use, if general use-cases can be
identified.

For example, a future release might include functionality to make notes
more suitable for the Hugo static site generator. This functionality
would be implemented as a postprocessor that could be enabled through
command-line flags.
2021-04-11 13:52:40 +02:00
Nick Groenen 138965a764
Add failing testcase for files with underscores 2021-02-15 19:41:27 +01:00
Joshua Coles 60d41672a5 Add tests for self-references
Note as there is no support for block references at the moment, the generated link goes nowhere, however it is to a reasonable ID
2021-02-09 10:36:39 +00:00
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 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 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 2edc2e87fb
Add more reliable non-ASCII tetscase 2020-12-07 23:32:25 +01:00
Nick Groenen c2de776148
Public release 2020-12-07 22:35:57 +01:00