Can Images in a Local Markdown File Be Converted into Internal Items During Import?

How much of this is actually written by you and how much by the AI?

In fact, I hardly wrote anything myself. I am new in Applescript and have only modified some existing code before. I just requested GPT-4 to write the code based on my ideas and then debug. This process took about 2 hours. Most of the time was spent on handling Chinese encoding and not knowing how to properly handle POSIX-formatted paths. Sometimes (especially in the two situations mentioned earlier), it couldn’t provide the correct results, so I had to figure out ways to help it bypass the issue.

This problem has been around for decades. When I was at Microsoft in the late 80s and early 90s, I helped write OLE (object linking and embedding). This included work on Microsoft’s compound documents, which basically turned a document file into a directory, and Apple’s packages seem to be the same. I never understood why writing this code was necessary, given that zip files already had this functionality.

Later, I worked on Scientific WorkPlace. Our file extension was .sci, but it was really a zip file, since it used TeX, and TeX has the same problem of having documents dependent on graphics which can get separated from the main document. Another problem with TeX is that when you try to delete outdated graphics file, you have no idea which ones are still needed by some TeX document.

Using Zip files solved those problems. Given that DevonThink is Mac-only, I would suggest looking at using Apple’s packages. If TextBundles are what I have seen Brett Terpstra discussing. then I would guess that they are also very close to zip files.

The .sci files in Scientific WorkPlace were zip files with no compression. If you opened one in a text editor, it was readable as text.

If TextBundles are what I have seen Brett Terpstra discussing. then I would guess that they are also very close to zip files.

Actually, .textbundle is akin to .rtfd.
.textpack is the compressed version.

And DEVONthink only supports display, not editing, of such files.

1 Like

One more example. Java .jar files are also zip files.
What Is a JAR File (Java Archive)? Definition from TheServerSide

1 Like

Agreed. I believe that TextBundle is the best solution. Managing Markdown files with images can be difficult, but I really need it to help me organize handwritten materials and display them well on different screen sizes. However, I don’t understand why it hasn’t replaced Markdown. In fact, when Bear was developing their new version, the transitional product called Panda was highly welcomed, and they are encouraged to continue developing this textbundle editing software. Its features include hiding Markdown marks when not editing and supporting handwritten notes within a single file.

Textbundles don’t replace Markdown. It’s a package containing the Markdown file and its assets.

Perhaps consider exporting that file from Bear as RTFD or DOCX format?

I don’t very often get in the weeds here, but I learned a few things from this discussion. All of the file formats mentioned (textbundle, zip, rtfd, etc.) are ways of treating a subdirectory as a file. So it stands to reason that anything you can do with these formats you can do also with a subdirectory. So I made new directory containing a single .md file and an assets subdirectory containing a single jpeg file. The .md file included the jpeg file in the usual way.

Then I dragged the new top directory in DT3. This resulted in a group (?) containing all the files and the markdown, with no changes, displays the graphics correctly.

To test an alternative I deleted the stuff I added to DT3 and then dragged just the contents of the first directory I made. This would be the assets directory and the markdown file. They appeared in DT3 highlighted, so that creating a group from them was trivial. So the result was the same.

So, adding a new file format that mimics directories is not necessary. Possibly there is still a pain point in moving lots of files since it may be necessary to decide which image files go with which markdown files, and this can be painful if all the image files are in a single large directory, but that is a problem unrelated to DT.

A screencast of what you’re describing could be useful.

Hmm. I’ll think about it.

A document format close to Markdown which allows to embed images is TextBundle. – Very unfortunately this format hasn’t gotten the traction it truly deserves… :unamused:

Thanks for confirming my point. Enjoy. :grinning:

Actually, that is technically inaccurate. The assets are linked, not embedded. The document and its assets are just stored in a package file, similar to how RTFD works.

2 Likes

Well, the resulting *.textpack file (here an example from the TextBundle.org site) is then one file where the original Markdown file and the images are embedded/contained.

I think TexBundle/TexPack this would be a fantastic format to write text with images, but as mentioned before, it is not widely used. (Note to myself: In technology often not the best solution succeeds, but something which becomes for other arbitrary reasons popular…")

In fact, I think TextBundle is too good to be popular. It makes migrating notes between different software very easy, which is not an advantage for commercial purpose.

1 Like

That’s not very convincing an argument, imo. PDF, for example, is certainly a “good format” (at least it contains all the images), and it’s widely available. OTOH, Word is perhaps not such a “good format”, but is still widely available. And what about (La)TeX? Is it “too good to be popular” or is it simply very good, but also not very popular because it has a steep learning curve?

Interestingly, most of the apps supporting TextBundle are macOS/iOS only. There’s only very little support for Windows and Linux. Perhaps because developers stopped reading the specification after the paragraph stating that TextBundle uses Apple’s Package as its container format – the next paragraph explains that ZIP is also possible.

IMO, TextBundle offers little to no advantages over a DT group with a subgroup assets storing all the images etc. You can save that group as a ZIP archive and have basically a TextBundle. Minus the JSON file, but that has nothing to do with the assets. But I guess a simple script could provide for that, too. So, what’s the point in supporting a format explicitly that is already supported implicitly?

2 Likes

Interesting way to look at it. (I have all my images in a database-wide assets folder, but maybe I should rethink that…)

Still having a format which goes beyond DEVONthink would be beneficial: Imagine everyone, not only DEVONthink people would use simply editable TextPack files instead of docx files…

And one often touted by @BLUEFROG before.

You might want to take a look at Script: Convert Markdown to TextBundle with images included. The script builds a TextBundle from an MD file, grabbing all images referenced in the MD. Instead of doing this, it could be modified to create a group and a subgroup assets, moving the MD file to the former and the images to the latter (or copying if moving is too intrusive). The changes should be minimal.

2 Likes

Cool script. Thanks. Will have a look at it.

1 Like