Help needed: Prism.js syntax highlighting in DT and MacDown

Hello, I brought another noob question here. :stuck_out_tongue:

I’m experimenting with DT and markdown. My current workflow is storing my notes in markdown format in DT and use MacDown, my system default, to edit them. (I searched the forum and found out Jim @BLUEFROG is a MacDown user too!)

As with most workflow experiments, I soon bumped into a minor annoyance. DT and MacDown both support syntax highlighting via Prism.js, but their syntax is different. In order to get the highlighting to work, a language- prefix before the specified language is required in DT, while this prefix must not exist in MacDown.

In other words, prism works this way in DT:

    ```language-c
    \\ Some code written in C
    ```

While in MacDown it works like this:

    ```c
    \\ Some code written in C
    ```

As a result, I cannot get prism to work properly in DT and MacDown at the same time. Is there some way to change how prism behaves in either DT or MacDown, so that syntax highlighting can work properly in both at the same time?

You’d have to talk to the Macdown developer.

The syntax used by DEVONthink is the official Prism syntax set by its creator, Lea Verou.

1 Like

Thanks for the info, Jim! I tried looking it up on google but couldn’t find out which syntax was the “correct” one.

You’re welcome.
You’d find examples on the Prism.js site

PS: I actually just began my learning Markdown with MacDown. I have it but hardly ever use it anymore. I do pretty much all my Markdown composition in DEVONthink.

1 Like

My brain still treats DT as “Finder on steroids” and I tend to do the editing in external apps, e.g. PDF Expert, MacDown, etc.

When I’m more at ease with DT’s rich feature set after more exploration, I’m sure my workflow will be much more streamlined. That feel when you’ve acquired the infinity gauntlet but have little idea how to harness its full potential :rofl:

We definitely don’t see DEVONthink as the replacement for all apps, even if they have some similar functions. Perhaps MacDown scratches your particular itch in a way DEVONthink doesn’t. We’re okay with that. But it’s definitely something you can explore in DEVONthink, if desired.

PS: The end of Endgame stunk. No spoilers, but :cry:
(PPS: Yes, I’m behind the times but I finally just watched Infinity War and Endgame last week. :open_mouth: :stuck_out_tongue: )

1 Like

Prism offers a syntax for code highlighting in HTML. What it offers is de facto standard for HTML.

The de facto standard for Markdown is GitHub Flavored Markdown, widely adopted over the internet and embraced by almost all Markdown editors, including MacDown, Typora, etc. It is also clearly documented in Markdown Guide under Extended Syntax.

So, it is DevonThink’s implementation that is out of step with the industry, and creating incompatibility with the common tools on the market. Once again, the Prism syntax makes sense for HTML (a full-fledged markup language), not for Markdown that is based on conciseness and simplicity.

All DevonThink has to do is to treat any unknown extension name in a fenced block as a potential language name and see if language-xxx is a recognized language in its database. Like this both Prism format and the industry standard Markdown convention will be supported and we will have highlighting for all the documents that we have sourced or created elsewhere.

As far as I know (and correct me if I am wrong), all important markdown renderers (redcarpet, kramdown, etc) and syntax highlighters (rouge, coderay, pygments, etc) support the same de facto standard syntax.

1 Like

Hello everyone

I love that Devonthink supports Prism. It would be awesome if I could still mark the most important parts of the code in yellow. Has anyone found a solution?
Thank you very much

image
image

Welcome @Linus

A code block ignores formatting by design, so this isn’t possible out-of-the-box.
Why don’t you just add comments as people normally do?

2 Likes

Thank you for your prompt reply. Sometimes it’s boring to do it like everyone else :smiley: