Skip to content

Conversation

@jforberg
Copy link

When this option is enabled, each parsed note will be considered to
start with a heading:

Title-of-note

even when no such line is present in the source file. The title is
inferred based on the filename of the note.

This option makes heavily nested note embeds make more sense in the
exported document, since it shows which note the embedded content comes
from. It loosely matches the behaviour of the mainline Obsidian UI when
viewing notes in preview mode.

@jforberg jforberg changed the title Add --add-title option Add --add-titles option Aug 24, 2021
@jforberg jforberg force-pushed the add-titles branch 2 times, most recently from d89491e to de76074 Compare February 4, 2022 13:42
@aadimator
Copy link

aadimator commented Mar 24, 2022

This feature would be greatly appreciated.

@jforberg
Copy link
Author

I wrote the feature as a special option, but I actually think it should be the default. The title of a note is logically part of the note.

When this option is enabled, each parsed note will be considered to
start with a heading:

  # Title-of-note

even when no such line is present in the source file. The title is
inferred based on the filename of the note.

This option makes heavily nested note embeds make more sense in the
exported document, since it shows which note the embedded content comes
from. It loosely matches the behaviour of the mainline Obsidian UI when
viewing notes in preview mode.
@jforberg
Copy link
Author

@zoni I have rebased my branch on yours now. I believe this feature makes obsidian-export much more useful for documents that use a lot of embedded notes. Maybe you could let me know what you think?

@zoni
Copy link
Owner

zoni commented Jun 24, 2025

@jforberg I agree this functionality should become part of obsidian-export. Is it absolutely necessary to implement this in the core parsing logic though?

I'm quite certain this could be implemented as a postprocessor instead because the Context should hold all the necessary information. I'm aware dealing with iterators and rewriting the markdown stream may seemingly be a little more complex, but extracting logic out of the core keeps things a lot more maintainable long-term.

See also https://github.com/zoni/obsidian-export/blob/main/CONTRIBUTING.md#design-principles

@jforberg
Copy link
Author

@zoni I don't see how that is possible given the current architecture. The postprocessor is fed a single document where all embeds have already been expanded. I can't see any information in the event stream that would mark the start or end of the original documents.

It could be possible if the event stream would be extended to include such information. But obsidian-export uses pulldown_cmark::Event type directly so there isn't any easy way to extend it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants