Skip to content

Conversation

kepano
Copy link

@kepano kepano commented Sep 12, 2025

Add Obsidian-Flavored Markdown #9883 using Markdown extensions. I could use some guidance on the approach to transclusion, and what to do on the writer side.

Extensions

  • comments: Parses %%text%% as comments (removed from output)
  • wikilink_transclusions: Parses ![[Title]] for full file transclusion
  • wikilink_heading_transclusions: Parses ![[Title#Heading]] for heading transclusions
  • wikilink_block_transclusions: Parses ![[Title#^id]] for block transclusions
  • block_ids: Parses ^id at paragraph end, wraps paragraph in Div with that ID

Uses insertIncludedFile for transclusion.

Includes tests and manual updates.

@jgm
Copy link
Owner

jgm commented Sep 12, 2025

Transclusion should be possible. See insertIncludedFile from Text.Pandoc.Parsing.
And look at the RST reader's treatment of include directives for an example of its use.

@kepano
Copy link
Author

kepano commented Sep 13, 2025

@jgm I think this is in a good place for your review now.

Some notes:

  1. I revised how wikilink images (e.g. ![[image.jpg]]) are parsed because the implementation of Image wikilinks for export in Obsidian #8853 via 09de84f seemed to be originally driven by Obsidian's syntax. In Obsidian, the ![[link]] wikilink syntax can be used to transclude any type of file (not just images), as well as headings and blocks within Markdown files. I consolidated all of these into a new transclusion parser (which could alternatively be called "include" or "embed" if you prefer).
  2. I ended up building on top of the Markdown reader instead of the Commonmark reader. Hopefully this gives flexibility to other apps that support Obsidian's syntax but not other Commonmark extensions.

@kepano kepano changed the title Obsidian extensions Obsidian reader extensions for comments and wikilink transclusions Sep 13, 2025
@kepano kepano force-pushed the obsidian-extensions branch from 479d5f1 to 7b2638d Compare September 17, 2025 01:33
@jgm
Copy link
Owner

jgm commented Sep 17, 2025

Can you rebase this into one commit, or a few logically coherent commits? All API changes should be clearly described and marked as such [API change] in the commit messages, so we won't miss them in the changelog.

@kepano kepano force-pushed the obsidian-extensions branch 3 times, most recently from 626148c to dbd8cdf Compare September 17, 2025 16:10
@kepano kepano force-pushed the obsidian-extensions branch from dbd8cdf to ad204c0 Compare September 17, 2025 16:20
@kepano
Copy link
Author

kepano commented Sep 17, 2025

Can you rebase this into one commit, or a few logically coherent commits? All API changes should be clearly described and marked as such [API change] in the commit messages, so we won't miss them in the changelog.

Done!

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.

2 participants