Snippets

Your software to me seems it would work very well regarding code snippets if you had syntax highlighting and some hookups to editors like textmate.

There is alot of really bad snippet apps on osx winning awards not because they even come close to DT but because they store snippets copying how you do it but with about 0.000001% of the features and slow (XML or SQLite storage). But the features they have like code highlighting are essentials you lack. They are all hacked up by bedroom guys…yet you have all this here already and just need to add in some of the things that would make it more comfortable to be used like this.

I have tried it sorry DT makes a only just passable snippet manager but with so little it could make a great snippet manager. Or even an off shoot version.

It would be nice to use the same app for docs, diagrams, media and code snippets but plain text snippets without hook up to to textmate are a bit boring.

Just an idea…checkout the snippet apps and you will see the features and how those in DT would make the ULTIMATE snippet manager on OSX.

1 Like

Thanks for the suggestion! Anyone else interested in this? See also viewtopic.php?f=4&t=10020&p=46796#p46796.

I am very interested in this. DT would be amazing as a snippet manager with its super powerful search features. I wonder how well the AI would work with it.

Reviving an old thread. Now that I’m using DTPO for pretty much everything, a code syntax-highlighting feature would be very much welcome. It would be great it this could be implemented in MD documents and not as a separate “code document” format, so that one could include text and code in the same document (similar to what Quiver does, happenapps.com/)

Thanks.

1 Like

@altostratus:
You already can do this. Lea Verou’s prism.js can be installed locally and linked to in the Markdown. I write long Markdown documents in DEVONthink every day, including sections of code and this works a treat for me.

Jim – do you want to post a little how-to setup tutorial for the community?

Yes, it would be nice. I downloaded both the CSS and JS versions and couldn’t figure out how to attach them to a MD note (the “Script” field apparently only concerns AppleScript).

Correct. You need both.

Quite simply, you put prism.css and prism.js in a directory and use this at the top of the document…

<link href="styles/prism.css" rel="stylesheet">
<script src="styles/prism.js"></script>
```…noting I put them in a [b]styles[/b] group along side my Markdown document.

Note: You can put this inline or in Markdown metadata [b]html header:[/b] at the very top of the Markdown document.

Then you just use a fenced code block with [b]language-XXXX[/b] in the first line [i](immediately after the three back-ticks)[/i], where XXXX is the language in lowercase. For example…
tell application id "DNtp"
-- do stuff
end tell
You can make your own Markdown template with this already in place for reuse. I have done this and have been using this template daily since the end of November. It works a treat (though I made some slight style changes to the CSS to fit my overall theme :smiley: )!

Thanks for the info. I can’t get it to work for some reason though. On the Prism download page, I unticked Javascript and ticked C#. I downloaded both CSS & JS and put them on the same level of my MD file (not in a “styles” folder). Then I added this at the top of the file:

<link href="prism.css" rel="stylesheet">
<script src="prism.js"></script>

And enclosed the code with this:

(code)

But I don’t get any syntax highlighting at all. Any ideas?

Thanks.

I just tested it and it looks fine. Are you looking at the plain text or the rendered HTML? It’s not going to show in the plain text.

I’m looking at the rendered Markdown document. Here are some screenshots.



Screen Shot 2018-01-13 at 20.11.40.png

It looks like you’re getting the background from prism.css.

Here is a quick sample I just put together (noting I removed the background for my own purposes. Otherwise, the prism.css is factory default).

Try quitting DEVONthink and relaunching.

Quitting and relaunching seems to have fixed it. Thanks a lot!

No problem.

Just thought I’d mention that, unfortunately, doing this results in a totally blank note displayed on iOS. When you edit it everything is there (and the note shows up in search results), but IMHO iOS should at least be able to show the note content in the default manner (i.e. code blocks as fixed-width text).

I’m not seeing an issue with Markdown documents.

Followed your suggestion for the Desktop app: force quit the iOS app and relaunched. All OK now. Thanks again.

No problem (again). :mrgreen:

Do you think you could share your template script or create one we could use to add the header information to a Markdown document? Sorry, not very good with this type of scripting. If not that’s fine, just wanted to see.

One other question, do you duplicate the prism.css and prism.js to a new directory or do you replicate it so that if you make a change in the original file, it will take place across the different directories?

Thanks!

You don’t need a script. Just select your MD document with the headers you want and do File > Export > As Template.