obsidian-enhancing-export icon indicating copy to clipboard operation
obsidian-enhancing-export copied to clipboard

Embedded notes are not exported

Open cloo opened this issue 2 years ago • 13 comments

When exporting a note, which contains embedded another note, the embedded note is not rendered. Instead, only the link is shown: ![[another note]]

cloo avatar Jul 31 '22 16:07 cloo

Hi, what's your expectation? export together? This doesn't seem like a good idea. Notes may be nested in loops.

mokeyish avatar Aug 01 '22 13:08 mokeyish

It is strongly recommended that you use standard markdown syntax instead of obsidian-extended wiki links. Non-standard markdown parsing requires additional custom development.

mokeyish avatar Aug 01 '22 13:08 mokeyish

It is natural to expect that contents of exported doc match the one you are exporting, isnt it? You dont expect any markdown code to show up, but the content. Yet the opposite happens.

Embedding other notes is a flexible way to compose complex documents (no idea why else would you nest files). Obsidian seems to be aimed at academic research, which usually involves complex content.

If exporting fails, it makes little sense to use nesting. Also diminishes its usability for publishing.

cloo avatar Aug 01 '22 13:08 cloo

Hi @mokeyish , Can we use a list or similar data structure to find all nested embedded links and then export all of those embedded files as well? My thought logic would be:

  1. Find all embedded markdown links if any.
  2. go through those embedded links just like any other linked markdown file.
  3. and This has to be done recursively on those embedded files.

The only condition we need to take care of is that a particular file is not exported multiple times if already exported. we can use the list we had initially to track these exported files.

ps. I haven't gone through the code base of this repo yet

nikhildr22 avatar Aug 11 '22 02:08 nikhildr22

@nikhildr22 Hi, which export format that you want to apply this rules? Finding all embeded markdown links just like find all images. here is the code https://github.com/mokeyish/obsidian-enhancing-export/blob/master/lua/markdown.lua

mokeyish avatar Aug 11 '22 04:08 mokeyish

https://github.com/mokeyish/obsidian-enhancing-export/issues/14#issuecomment-1211497364 @nikhildr22 Unfortunately, the author is right, recursion is a problem.

Of course, if you are looking for a plugin that can support the export of embedded Notes, you can see this https://github.com/oliverbalFour/obsidian-pandoc/issues/5

But this library and plug-in still cannot be supported! [[Xxx^d83ds]] This type of block reference forming export. according to:https://github.com/OliverBalfour/obsidian-pandoc/issues/23

However, even more, unfortunately, the repo has not been updated for a long time, and the author of the library is very busy according to https://github.com/OliverBalfour/obsidian-pandoc/issues/139, so it is expected to make your own rules and merge with this library. It looks like the best choice.

abserari avatar Feb 07 '23 09:02 abserari

Mgmeyers Easy Bake plugin handles this issue without infinite loops:

The recursion will end if a note links to a parent note (so it can't go into an infinite loop) or all links have been processed. In theory this could mean easy bake could turn your whole vault into a single note Although your notes would have to be linked in a way that creates a hierarchy rather than graph for that to happen [...] Yeah, it keeps track of all the ancestors and doesn't embed links to any of them

Source: https://discord.com/channels/686053708261228577/969644355042287717/1143309258675453962

FeralFlora avatar Aug 26 '23 00:08 FeralFlora

I have a quite similar issue. I hope it is not to much off-topic, but I think at the root it is the same issue. For me it is not that much about embedded notes but about other auto-generated content like a dataview which creates a table or the output of the task plugin which shows my completed tasks. From time to time also a embedded note.

At the moment the exporter exports the source code of the note, while I assume most people want to export the content they see on the screen in reading mode. No matter what they use to generate it.

I don't see the issue of infinite loops. I think for regular users this is hardly a issue because this would also create the same loop within Obsidian and break their note. But I get that a tool like the exporter also want to prevent malicious behaviour by a bad actor. I think this could be addressed by adding a (configurable) max number of links you follow. Similar like tools such as wget which allows you to fetch websites and follow links.

schiessle avatar Sep 05 '23 15:09 schiessle

I have a meta note which is effectively a table of contents for around 20 other notes. I'd like to export all these notes together and set styling with pandoc (the builtin export works ok, but the way it exports themes is not great).

I am able to send my links past a linter to format them in standard markdown, but this only creates a link to a place on disk where the original .md files are.

Is there any way to export the contents of links inline as if they were in the same note?

mrlinuxfish avatar Sep 12 '23 23:09 mrlinuxfish

@mrlinuxfish Transclusion is not supported by Pandoc at the moment, but the issue is tracked here (since 2012!): https://github.com/jgm/pandoc/issues/553. There are some scripting workarounds mentioned there that might be viable to implement in Enhancing export.

For now, you could give Easy bake together with Pandoc reference list a try. The former enables transclusion exports, and the latter renders citations in the export.

FeralFlora avatar Sep 12 '23 23:09 FeralFlora

@FeralFlora Thanks, it looks like Easy bake is exactly what I'm looking for

mrlinuxfish avatar Sep 12 '23 23:09 mrlinuxfish

Forgive me, I'm not a programmer, but I don't understand the problem. If recursion is a problem, can't you simply not do it? That is, only read embeds in a top level merge document, not on the ones that are embedded? For instance, if I have:

Merge Document

[[File 1]] [[File 2]] [[File 3]]

And, for some reason, [[File 3]] has a link to [[File 4]], can't that just be ignored? That is, only read embeds in the document the command is run on, not in the embedded files linked from that document.

This would be good enough for my needs.

kerim avatar May 10 '24 23:05 kerim