Please make it possible to include JS/CSS files in markdown rendering from Application Support folder

Proposed improvement

I use the built-in Prism every day in my DEVONthink markdown documents to improve their appearance. I would like to customize the implementation for my needs, such as expanding the syntax highlighting. It would be possible today for me to manually link all my markdown document to my own Prism implementation. I have tried this. It works but has challenges.

Challenges without the proposed solution

  • It requires a special location for my Prism implementation.
    • In a database This is would work and work across upgrades but only for the database where the implementation is stored. This requires that I link out from each markdown document.
    • In a neutral location on my local filesystem This would work across upgrades and would be consistent for all databases. This requires that I link out from each markdown document.

Better location

-The Application Support folder This is a better location but DEVONthink would need to be modified to implement this. It would work across upgrades. It would work for all databases. It would not require that I alter any existing or future markdown documents. It would permit near complete flexibility.

The proposed solution addresses these key challenges because

  • It would permit greater flexibility for markdown rendering customization because changes would be made in one place and existing document would not be modified.
  • It would permit a location that is both resistant to upgrades and accessible from any database.
  • It would permit a consistent user experience for those that wish to customize their markdown rendering. This means it could be described in the DEVONthink manual.
  • It would permit users to include their own JavaScript, CSS, or other content in addition to or in place of Prism. Who knows what people may come up with? It separates the semantic markup from the presentation experience.
  • It would prevent the need for users to alter their existing and future markdown documents. (This is a big deal for me because I have many markdown documents and plan to have many more.)
  • It would permit users who do not wish to alter the markdown rendering, to continue to use DEVONthink exactly as they do today without noticing any changes.

Proposed solution

Have a file in the Application Support folder that is always included when a markdown file is rendered by DEVONthink.

The file would be empty by default. This would ensure it would not alter the behavior of the markdown rendering unless action was taken by the user.

A user who wished to customize the rendering of their markdown documents could include links or other content in that file to their own prism.js and prism.css. Those custom Prism files could reside in this same location in Application Support as the include file. This would permit the customizations to persist over upgrades, much like they would if they were stored in a DEVONthink database.

It would also permit users to share the markdown rendering experience across many DEVONthink databases since the files are equally available to all the open DEVONthink databases.

I am a software developer and I am happy to do (some) of the work, but would obviously need permission and direction from DEVONtechnologies. I do not know how this is handled with DEVONthink.

Please consider this proposal.

1 Like

Could you explain why you prefer using external files. I’ve made a similar suggestion here, which builds on the way you can already specify a custom CSS file via a URL, so it can be either a local file, or an item link. We just need a second options like that for a JavaScript file, and we should be all set.

I prefer “my” suggestion because it is more general, and potentially extends trivially to DTTG as well.

You have a good point. The issue I have with a preference for a JavaScript URI is that DEVONthink knows it is a single JavaScript file. I could add what I want in that JavaScript file but now it is updates in two places.

It limits my flexibility because that entity must be JavaScript. The same is true for CSS etc. In the case of JavaScript, DEVONthink would be generating the script tag for me and I would be providing only the URI. A file permits me to add my own tags for my own inclusions. I could add as many or a few as I like.

I think I see a compromise.

What if DEVONthink had a dialogue in the preferences, much like the Annotations dialogue?

One could enter anything they like, just like a file on the file system. It would be far easier to deal with because one could make modifications without needing the command line. Nobody would need to know or care where that preference is stored so long as it is accessible to any open database.

There could be a default template with the script and css tags needed to include a JavaScript or CSS file by URI. Most users would simply add their URIs. Any valid URI should work fine but they would, of course have different accessibility restrictions.

  • Local file: Should be accessible by any open database
  • Item link: x-devonthink-item: . . . Should be accessible so long as the database with the DEVONthink item is open.
  • Remote URI: Should be accessible so long as one has connectivity to the remote site.

I want to also be sure that whatever is added affects only markdown rendering.

There could be a default template with the script and css tags needed to include a JavaScript or CSS file by URI.

You can already create your own template Markdown file using any of the JavaScript or stylesheet linking methods… or even one with default internal styling.

So long as it changes the rendering of the markdown file and not the markdown document its self. I only know how to make a document template, not a rendering template.

Any news?

1 Like

No. There is no news on this.

Just curious but what exactly does (or would) your script do?

Not sure what you mean with this answer to my post, please clarify!

A global stylesheet can be already specified in Preferences > Markdown > Media, therefore I assumed that you want to specify a JavaScript file in the same preferences pane too. And now I wonder what the purpose of this script is. Just customised Prism support or anything else?

Though you didn’t ask me, I’d answer: Possibly add functions that are not available (yet). Like

  • unsupported markdown formats (like check boxes in ancient times :wink:
  • special HTML processing that’s not available in the current MD processor: maybe generating a TOC automatically or including images as data-urls or …
1 Like

The next release will support this.


:heart_eyes: :tada:

Thank you. I am excited for this!