Feature Request: Export full text of transclusion

Hi,

I’d like to request a menu item allowing export of a transclusion notes’ text contents (i.e. what is shown in preview) as plain text.

A ‘select all’ button and then copying would also do it, but ‘select all’ does not seem to be available. Selecting and scrolling down is not practical for long notes.

Appreciate any input and your consideration of perhaps adding this in future releases.

No promises but the request is noted.

Thank you @BLUEFROG

Here’s a little teaching edition script that may be useful…

tell application id "DNtp"
	if exists (content record) then -- A document must be selected and displayed in the view/edit pane or a document window
		set currentRecord to content record -- If it exists, use it
		if (type of currentRecord = markdown) then -- Check if it's a Markdown file
			set plainText to (plain text of currentRecord)
			if (plainText contains "{{") or (plainText contains "![[") then -- Does the file appear to have transcluded data
				set renderedContent to (rich text of currentRecord) -- Get the rendered text, including paragraphs
				set plainTextDoc to create record with {name:(name of currentRecord as string) & " Text", content:renderedContent, type:txt} in current group -- create a new plain text document from the rich text content
				if exists plainTextDoc then open tab for record plainTextDoc -- Optionally opening the newly created file
			else -- Error is there is no transcluded data detected
				display alert "This file doesn't appear to have transcluded content."
			end if
		else -- Error if it's not a Markdown file
			display alert "This is not a Markdown file."
		end if
	else -- Error if there's no content record, i.e., no file being viewed in the view/edit pane or a document window
		display alert "Please view a Markdown document to export the transcluded content to plain text."
	end if
end tell

Thanks!
So I think you’re suggesting a workaround here, right?
First one would convert the transclusion items into plain text in DTPO and then use the plain text files in DTTG? This would bring some added maintenance with it, though…

Did you try the script?
You don’t convert various Markdown files to plain text then run the script. You select a Markdown file with transclusions, run the script, and it generates a plain text file of the content including the transcluded data.

I just found out that when “convert to Markdown” is run on a markdown document with transcluded contents, the newly created item includes all of the text. This also includes the original formatting of that text in the transcluded items.

This is pretty cool, and sort of a hidden feature in my view! I’m finding this super valuable actually, so if it’s kinda sorta unintentional then I’d ask to leave the behavior as-is :wink:

@BLUEFROG’s script works but it doesn’t retain the formatting, since it uses the rich text source. At the time, it was the best solution.

Now I only wish that the “convert to Markdown” option was also available for Markdown documents in DTTG. Here, that option is not available when selecting Markdown items.

Great find! It’s always worked for Convert to Rich Text, which is what I’ve been using as a workaround up to now, and then you can then simply use Convert to Markdown on the .rtf document to get it back into Markdown, but the result isn’t completely identical to the original preview (line breaks aren’t always restored). This simpler route is perfect, even if the functionality is an accidental by-product of code intended for cross-format exports. It’s a powerful enough feature to be worth mentioning in the manual.

1 Like