Hi, I have a sweet system for spontaneous note-taking in which I create a markdown file from a DTP template and then open it in Typora. I often take screenshots as I take notes, and paste the image into Typora. The problem, of course, is that that image isn’t actually in the DTP database; it’s just hanging out somewhere on my computer. This means the images don’t get synched.
What I’d really like to do is paste the image and have Typora automatically upload the image to DTP under some sane path (i.e. the same group, named by date and time). There’s a dialog that looks like it could work, and I bet there’s a command I could type into this “custom command” box that would work.
Does anybody have a clean and “best practice” way of doing this? ChatGPT suggests some things that might eventually work via applescript files, but I’d like to ask this question here before I struggle with some convoluted hack.
A group is not a “path”. Nor a folder. It is just a logical grouping of items, not a physical one.
AFAIK, Typora creates Markdown files. Those are simply text and should contain the path to the image(s) in the image links. So, a smart rule running on import of said MD files could scan them, import the images to whatever group you like in DT and then adjust the MD link accordingly.
Scripting is not a “convoluted hack”. Not more than a “custom command” to upload an image. Though, what ChatGPT writes for you might well turn out to be mostly hallucinated. There is lots of sample code here in the forum written in JavaScript and AppleScript that actually works. Enough to get you a good start.
I’m not importing the markdown file; I’m creating it from a template in DTP using applescript. The markdown file is already in DPT in the proper group before I start typing the notes in Typora.
Right, that’s what I meant by ‘convoluted’. I find ChatGPT gets me about 80% to a solution that works, but it’s usually more complicated than it needs to be. And perhaps there exists a x-devonthink:// URL format for DTP that will just handle this kind of thing automatically.
You should know where this is and it’s in the ~/Library/Application Support/typora-user-images directory.
In order to do what you’re trying to do, you should create a working directory in the Finder and index it. Then create and work with your documents in that directory.
You should also enable Auto escape image URL when insert [sic] in Typora’s Settings.
This is exactly the problem I hit when trying to use an external markdown editor (like BBedit or IA writer) or Marked2.
X-devonthink links don’t work and, as you point out, neither do relative paths. The only way is to either export the files prior to opening in the external editor or have the files in externally indexed folders
Some editors will work with textbundles. Out of curiosity, is there any plans on having DT read and write textbundles (with included images)?
@chrillek makes a good point. I think it’s not super important to me if the images can be viewed in Typora. Using the x-devonthink link would be somewhat fine. But indeed, this isn’t ideal.
Yes, but I want the files to be synched to my cell phone, and indexing won’t do that (or is there a way to do that?). Also, I want to have all the files for a note located in the same area (group). If I want to delete a note, I want to also delete the images linked to it. If the images are named according to the date and time, it’s easy to sort and associate the files with each other.
I’d like to take notes in DEVONthink, but man it’s not pleasant. I have to use too much brainpower, and I really want the whole system to stay out of my brain when I’m trying to concentrate on something else. That’s why I like Typora; I can type exactly as I want the info to appear, without even having to look to another rendered area to ensure it’s being entered properly.
The files I’m creating are just yyyy-MM-dd Title.md located in a particular group called Meetings > 2024, which I update in the Alfred script every year. Veeeery simple.
Textbundles would be amazing if Typora or DTP ever supports them. That seems to entirely solve the problem.
Everything has been said about Markdown (or rather HTML because that’s what we’re talking here, really) and images. More than once.
MD/HTML can include images (and so can MD, and that has also been discussed – there’s even a script floating around which embeds image data in MD). It’s just not pretty anymore (read: bloated and not legible).
Textbundle is around for at least 10 years. It seems that the response to it was lukewarm at best (its supported almost exclusively on macOS). There is, btw, another script floating around here that packs MD with its related images into a Textbundle. DT can display it, and there are a bunch of apps (eg Bear, Ulysses, Marked2 and Agenda) claiming to support it.
So maybe that’s the way to go.
Or perhaps choosing a format that is better suited to handle images is the way to go. MD was developed to make writing HTML easier. Not as a replacement for Apple’s Notes or similar apps.
I experimented a bunch and arrived at the following conclusions.
Textbundle support isn’t sufficient yet. The only app that was even close to working properly with DTP was Zettlr. Everything else either (Bear, FSNotes, Ulysses) restrict themselves to import/export, or (Textbundle Editor) are drastically too user-unfriendly. Zettlr actually worked, but was not pleasant to work with; it felt like first generation support. Since DTP ToGo doesn’t support editing, using this format at all makes me slightly nervous.
Scripting an import. So the alternative is to use the Typora image uploader to import the pasted image into DTP. I wrote a script to do that, but it’s got a bunch of limitations.
on run inputFiles
tell application "Typora"
set documentName to name in front document
end tell
set filePaths to {}
-- Rename and import the image into DTP.
tell application id "DNtp"
-- We can only dump these images into a pre-selected group. Other group's images will have to be sorted later.
set destinationGroup to get record with uuid "YOUR UUID HERE" in database named "YOUR DATABASE NAME HERE"
-- Iterate over all the input files (on paste there's only one)
repeat with inputFile in inputFiles
set importedFile to import inputFile to destinationGroup
-- This stupid "http" string is so Typora will identify it as a URL and use it. Must be removed after pasting.
set end of filePaths to "http://removeme " & (reference URL of importedFile)
-- Rename the imported file with the (probably accurate) note filename so it is sorted nearby
set theName to documentName & " - " & (name of importedFile)
set the name of importedFile to theName
end repeat
end tell
return filePaths
end run
So to be complete, it has the following annoying traits I can’t think to get rid of:
The import group is hardcoded. Luckily, most of my impromptu notes go into the same place, and otherwise it’s easy to resort the images later.
The URL returned by this script is “detected” by Typora, so at least http:/ (yes, one slash) needs to be at the front. Since DTP links don’t have that by default, I had to add it. It’s fairly quick to remove after paste, so I hope this isn’t too annoying later.
Because I’m using DTP links, both DTP and DTP ToGo will display the images. However, DTP ToGo won’t show the image unless you download them, and Typora won’t display images using the x-devonthink-item:// reference. That’s good enough for now.
If you cut and paste an image with a x-devonthink-item:// reference, Typora “helpfully” prepends the URL of the file you’re working on. Press Cmd+Z to undo that help.
It’s not ideal, but at least images will be synced and stored and I can print them to PDF for sharing if necessary.
I just realized I have another annoying trait of this method:
Typora always uploads images; this script doesn’t (can’t?) tell if the note comes from DTP or is just a local file with different rules. So if you use a lot of images external to DTP, this might be a poor solution.
Probably fine for me though. I don’t really have anything outside of DTP.
I’m a very heavy Typora user, though I don’t really use it with DT. Typora lets you customize where images are stored, in the Image pane in its Settings window. I have mine set to “Copy image to current folder (./)”. When I start a new note, I create a directory for the Markdown file (with the same name as the root of the Markdown file name), so after my note-taking, the Markdown source and the images are all together. If I think I’ll be editing the document in the future, I’ll keep them that way. But in most cases I just want to archive the notes, so I render to a PDF, and keep either just the PDF, or (most often) both the PDF and the .md file (in case I want easy access to my textual notes).
Incidentally, I was one of the (many!) Typora beta testers, and during the beta period I suggested creating some kind of Markdown bundle format that bundled together the source and images (or other attachments) as a single entity in the file system. A dev responded that they were considering adding support for an existing file format that does just that. I can’t find the discussion, but it was either the TextBundle format, or something like it: Welcome to TextBundle.org!. That was at least a couple years ago, and it’s not been added, so I suspect that the Typora team is no longer considering this.
Yes, but not while rendering the Markdown at your cursor as you type, in a single window, including rendering MathJax on-the-fly, and flowchart and diagram markup, which is Typora’s claim to fame.
I’m someone who has steered away from WYSIWYG editors for decades; I prefer WYSIWYM editing. For scientific writing, at this point I pretty much think in LaTeX. But for some reason, for Markdown the “Typora way” just really works for me. I suppose it’s because the markup language is so constrained that for the simple documents it suits, what you see is what you mean. Two-pane editors just seem very awkward now. YMMV.
That said, for working on significant scientific documents, I still go to a plain text editor and write unvarnished LaTeX.
I never have the patience to finalize my notes to PDF (or do anything else for that matter). I want to just type and then have it magically come up in searches months later. So if it’s not started fully in DTP, it never finds itself there. The method above (practiced in the last week), has worked fairly well.
I also have similar feelings about Typora. I’ve tried a lot of these editors, and Typora adds something that frees my mind a bit. I think the render-as-you-go (without the awkwardness and delay of checking a second window) makes it easy for me to double-check that I’m marking up what I expect.
I’m still playing around with it. The “convert to TextBundle on image import” option breaks DTP because the filetype changes. But I bet I can convert my templates to TextBundle in the first place, and then I won’t have the problem. Testing ongoing…
Update an hour later…
Indeed, changing my templates to TextBundle works as expected.
I saw one bug in DTP though:
DTP doesn’t handle spaces in the TextBundle image paths. If you escape them with %20, DTP shows the image properly.
I submitted two bugs to Typora that are cramping the use case here: