mokeyish / obsidian-enhancing-export

This is an enhancing export plugin base on Pandoc for Obsidian (https://obsidian.md/ ). It's allow you to export to formats like Markdown、Markdown (Hugo https://gohugo.io/ )、Html、docx、Latex etc.
MIT License
347 stars 23 forks source link

feature suggestion: remove wikilinks before export #158

Open yanivabir opened 9 months ago

yanivabir commented 9 months ago

I saw that enhancing export can now render wikilinks correctly.

It would be great to have the option to drop all links, replacing them with plain text - since most internal obsidian links won't work for an exported document.

This is especially useful if you want to have the citation keys be links to the your paper notes in obsidian. If you have something like this:

[@cite_key1; [[@cite_key2]]]

the latter reference won't be rendered correctly - rather you get a link with the cite key as text.

mokeyish commented 9 months ago

Please look into pandoc, or ask its community if this is possible.

robquill commented 3 months ago

This feature is implemented as part of the obsidian-pandoc extension (which appears to be an alternative to this extension).

See https://github.com/OliverBalfour/obsidian-pandoc/issues/4

Unfortunately the export to Word didn't work for me using obsidian-pandoc, but perhaps the same feature could be implemented in this extension too. I think it should be part of the extension, rather than part of pandoc itself.

josephgarnier commented 4 weeks ago

If it helps, I've developed a Pandoc filter that replaces Obsidian syntax with common Markdown syntax, including WikiLink (it can also converts Obsidian comment %% to HTML commentary).

https://gist.github.com/josephgarnier/ab5f9c8750b6bfa08c38fe130546cf7b

See the function obsidian_converter.convert_wikilink. Its description is:

---Parse inline block to substitue all wiki links by their alias text or their page link as text.
---
---For example:
---- `[[Link/to/my/page]]` become `Link/to/my/page`
---- `[[Link/to/my/page|Page alias]]` become `Page alias`

Let me know if you need some help to use it.

mokeyish commented 4 weeks ago

@josephgarnier Would you like to integrate your pandoc filter into this plugin?

In fact, it is just to modify the following file. I remember that pandoc can specify multiple lua-filters, and it will be executed in sequence.

https://github.com/mokeyish/obsidian-enhancing-export/blob/main/src/export_templates.ts

josephgarnier commented 4 weeks ago

@mokeyish sure, i'll do a PR.