How to enable Prism on DT 3.5?

Correct. And to reiterate Criss’ comment: “Not all languages are supported, see release notes. Otherwise the embedded Prism files would be much larger and e.g. bloat the code after converting Markdown to HTML.”

Devonthink team thanks for the 3.5 update. I feel there’s a need to outline how to use the custom Prism file since it helped me centralize my SQL, Visual Basic, Batch, Powershell, etc. code syntax, snippets and historical versions into DT as opposed to having them scattered across two other apps and Outlook folders. Code-block works on both Devonthink Mac and iOS as shown below using this method.

iOS Screenshot

One Time Setup on Mac

  • Go to prism website

  • Click the big download button at the top

  • Check off the theme and languages you will be using

  • (Optional) Check off plugins like Inline Color, Normalize Whitespace (for removing extra lines in rendered code), and Copy to Clipboard Button. Unfortunately, Line Numbers didn’t work for me at the time of this writting.

  • Download both the CSS and Javascript file using the big download buttons on the bottom of the page.

    • If you are using Normalize Whitespace and want your code to wrap around, insert the “break-line”: 80 line into the javascript file method Prism.plugins.NormalizeWhitespace as shown below.
	(Prism.plugins.NormalizeWhitespace=new e({"remove-trailing":!0,"remove-indent":!0,"left-trim":!0,"right-trim":!0,"break-lines": 80})

Be sure to check your quotes whenever you copy / paste as the open/close quotes can be copied instead of the general quote used in code

  • Place both files in your database
  • Copy the Item link for each file by left clicking on the file and paste the x-link between the quotes like shown below:

For CSS File

<link href=“x-devonthink-item://0A9B8CBC-D620-4257-B1A8-71E363C0EDBA” rel=“stylesheet”>

For Javascript file

<script src=“x-devonthink-item://96C2CDA1-86FE-4DE4-8924-92C7541A432C”></script>
  • using the devonthink item link allows you to move the files around the db without breaking the connection

  • place this at the top of every markdown document where you would like to use the code-block, I use a text expander to automatically insert it by typing .syntax

  • As mentioned above, prism uses the language-xxxx in the code-block to identify the language you are working with.

    • The language must be spelled out just like it is listed in the prism website otherwise it will not highlight ie. use language-excel-formula NOT language-excel
  • Be sure to save the document to see the code-block highlight or when changing from one language to another

    • Reboot Devonthink if necessary



Thanks for the comments.
They are find if someone wants to customize their prism experience. The 3.5 build allows use of prism without needing to explicitly link the css and js files, though it only supports a smaller number of all the supported languages.

@MosCool_Noel, any luck with getting line numbering to work?



Question: I see that a generated prism.js is stored in the .app folder structure and that it seems to have the 4 prism defaults with a few extras. Is there a way that at some point in the future that could be in the Application Support (or similar) folder so that it could be overridden with a customer-generated prism.js?

I respect that you guys want to avoid bloat but I also personally don’t care about the bloat for my own purposes in previewing the files. I would love to have a way to generate and use my own customized prism.js that wouldn’t involved putting it in the .app folder and have it being overwritten by updates.

Why don’t you just disable it in the preferences, then link to your own local copy of it?

Yes, include the following html line after the header that calls the prism files.

  • be sure the Line Numbers plugin is included in both the js and css file.
<section class="line-numbers">

1 Like

Yeah I guess thats doable. Could create a “code snippet” template.

@MosCool_Noel, that’s fantastic!

works like a charm, thx for sharing!


I have such a thing myself. :slight_smile:


Since the DT’s built-in Prism support doesn’t have soft wrapping for fenced code block, is there a way for us to include some header in the markdown to make it happen?


You can use a CSS override like this…

<style type="text/css">
pre, code {
white-space: pre-wrap !important;
1 Like

Thank you very much!



I’m really excited about adding custom Prism support, but I can’t seem to get it to work:

I downloaded the JS and CSS files from Prism’s website (both version 1.20.0), then dragged both into my open Personal database. I copied the item link using the context menu and pasted them into the link/script tags as shown–I checked them more than once to make sure they’re correct.

I noticed that the section tag doesn’t show in the rendered Markdown preview, but the link/script tags do, as though they aren’t being processed. Why might this be?

I checked to make sure I have JavaScript enabled in the Web Content preferences:

Also, built in Prism support is disabled, though checking/unchecking this box had no effect:

Any idea what I’m doing wrong here? I’d appreciate any advice or suggestions. Thanks.

The header section that calls the files has open/close quotes, probably from copy/paste. Retype them to replace them with the general quote that look like this " "

instead of this “ ”

1 Like

That did the trick. Thank you very much! This will really help me organize my work notes. :smile:

Thanks for this.
What is your capture flow?
I wonder how to effectively capture, especially on the IOS (is there a way to create the necessarily boilerplate per shortcut maybe?).
This old discussion suggested to use a service on mac. Is it how you guys use this with prism support?

You may want to start a new thread on how to capture snippets on iOS. I’m mostly on the Mac but if I were on iOS I would look at Text Replacement to expand the prism header on typing a keyword: Look in General > Keyboard > Text Replacement.

Good idea. I used KM to do same for the MAC now. But i really wonder if there is a way to select text on IOS and then use some magic to bake it into a proper md note with prism support directly in DTTG. This would open a way to sync this later with e.g. Anki specifically for code snippets.