How to Use File Transclusion

If you’ve ever needed to consolidate content from multiple documents into one, you likely have used copy and paste. But if you make edits, they have to be made to all involved documents. Wouldn’t it be nice if you could keep the documents separated but show them as a single document? You can with a Markdown feature in DEVONthink: file transclusion.

File transclusion displays the content of other documents as if they’re part of the Markdown document you’re working on. Typically used for other Markdown documents, it also supports plain text, rich text, PDF documents, and sheets. You can trans­clude images, though we recommend using the regular Markdown syntax instead. It is even possible to trans­clude audio and video documents. The document you want to trans­clude just needs to be in the same database as the Markdown document.

To add a transclusion, use one of these methods:

  • Start typing double curly braces {{ and the name of the document you want to trans­clude. An autocompletion popup appears, so you can select a document in the same database. Select one and press Return to insert the name and close the braces.
  • Type the name and extension and braces manually. This also works in DEVONthink To Go.
  • Hold the Control key while dragging and dropping into the source to insert a transclusion.

The contents of the trans­cluded documents immediately appear in the preview. Change the order in the source and it changes the preview.

But note, the trans­cluded content is only a visual representation. You cannot select and edit it. To make changes to it, you need to open the document. These changes will be will be immediately reflected in the preview. Also be aware file transclusion isn’t supported in all third-party Markdown applications.

5 Likes

I didn’t even know this feature existed! Thanks for posting about it. Now that I’ve tried it, I’m absolutely going to use it in longer form writing. But I do think I ran into a problem. If I transclude more than one file, only the last one actually appears in the preview pane. Any prior files just appear with the double curly braces around the file name. Am I missing something?

It’s working as expected here.
Post a screen capture. We can’t see your screen from here.

Sure. Here you go. My tagging strategy document isn’t included at all in the preview beyond the same double-curly-braces invocation from the editor, but my tips document is. If I flip the ordering of the transcluded documents, then the situation is reversed; i.e., the tips document is shown as the markdown text while the tagging document appears in full.

That does seem weird.

Transclusion also works with item links, i.e.{{x-devonthink-item://...}}. Does that make any difference?

Did you manually type that?

Two updates. First, using item links worked correctly, showing me the contents of both documents in the preview pane. And second, no, I didn’t type what appears in the screenshot above manually: I typed a couple characters, used the up/down arrows to select the articles that popped up, and then pressed ‘Enter’ to select the ones I wanted. DT filled in the names for me.

I find after deleting the text entirely and recreating the two links via the type-a-few-characters-and-use-the-popup method now works for me. Maybe some corrupt character got included or something? A space that wasn’t visible? I don’t know, but it’s working now. I’ll post again to this thread if I have the issue again. Weird.

1 Like

Another update to this thread. Even though the transclusion feature now works fine on my MacBook Pro , it does not work correctly in the current version of DEVONthink To Go 4 with the very same synced document. See screenshot for details. Interestingly enough, it seems to be evincing the same problem I had with my laptop.

Das kann ich bestätigen. Auf meinem MacBook, aktuelles Betriebssystem, und DT V4.2 Cassini läuft es problemlos, auf DTTG 4.1 Lagrange die gleichen Probleme.

Are both documents to be transcluded downloaded? Are they in the correct location?

If you can share the documents in question it would be great if you could IM them to me, best with a screenshot of where they are located in your database in relation to each other, so I can test it myself. A screenshot of your Markdown and WikiLinks settings could help too.

Ich habe auf Grund dieses Forumbeitrages mir ein Musterdokument als MarkDown einmal auf dem MacBook und in DTTG jeweils in der selben Datenbank angelegt und das beschriebene Verhalten festgestellt. Die Dateien habe ich bereits gelöscht. Ich werde es noch einmal versuchen und dann gerne die Dateien schicken.

Ich habe eine Mail mit den erbetenen Informationen geschickt.

Yes both documents are downloaded, yes they’re both in the correct location. All three documents are in the same database and group in DEVONthink. I’m attaching the three documents to this message in a zip archive.

TransclusionDocs.zip (5.6 KB)

Interestingly enough, now I’m having the same problem again on my MacBook Pro. I can delete and re-add the transclusion links through the method I was using before, and only the second document’s contents are included in the preview pane as before. Hmm…

It’s caused by curly braces {{ in the document, the next release will handle such unbalanced braces.

1 Like

So far, neither restarting the app nor restarting the MacBook Pro fixes the issue.

Ahh, indeed!

@Phileosophos: Escaping the braces would also have rectified this: \{\{.

Aha! Thanks for explaining. That helps my sanity :slight_smile:

Hear, hear! Transclusion is key to my batty idea of how to outline. One tree of groups and subgroups are factual items. Another group has Markdown files for beats/chapters/whatever.

A transcluded fact can contribute to many chapters, and each chapter is a chance to accurize, if that’s a word, the facts.

But a question arises.

I can drag and drop a file from one DT window into an open Markdown document. Is there a quick way to make that a transclusion instead of a regular link?

In other words, I’m an end user, always ready to quibble about something.

Transclusion is liberating. Dragging and dropping files as links lets me cross-reference without slowing down.

Much rejoicing.

2 Likes

Just hold the Control modifier key during drag and drop.

2 Likes