Sharing Markdown tips & tricks

Hello all

Since DEVONthink nicely integrates MultiMarkdown and many users make use of it, I thought it helpful to exchange some tips & tricks. I’ll start with a list below.

For regular users none of these will be new, but (as a fairly new user) I figured them out rather slowly, so I thought I’d share.

Please comment to expand the list!

Cheers
Eeljen

[size=150]1. Render markdown in DEVONthink[/size]

Use shortcut alt-cmd-P to quickly switch between the rendered view and the raw text.

Personally I prefer to display this preview by default. Chose your default under Preferences > Media.

For more thorough writing and editing, I suggest using an external editor (such as Byword or iAWriter).

[size=150]2. Include a custom .css file[/size]

Add a custom .css file to render markdown with a html-snippet. Just add the following link to your markdown documents:


<link href="file://Users/path/to/css_file.css" rel="stylesheet">

Make your own or use some existing styles, here for example: https://github.com/ttscoff/MarkedCustomStyles

Reusing the same file in all of your documents allows for easy adjusting of the style.

You could also use a DEVONthink link (see below) to refer to the CSS file

Additional tips:

  • For easier access, add this code snippet to text replacements under System Preferences > Keyboard > Text. Make sure ‘Text Replacement’ is enabled in DT under Settings > Editing
  • Save a custom template that includes this code snippet, so that you have it in all your new markdown notes.

[size=150]3. Link to headers[/size]

Link straight to a header within your document.

If you have a header called ‘## Topic 1’, you can link to it in MarkDown, with: ```

[link][Topic 1]



[size=150][b]4. Include a Table of Contents[/b][/size]

To include a Table of Contents, add ```

{{TOC}}

```.

Note that this only generates consecutive headers, starting from base 1. So if you use headers #, ## and #### in a file, the TOC will only include # and ##.

[size=150][b]5. Use devonTHINK links[/b][/size]
This is rather basic, but while I'm at it:

Use [i]x-devonthink-item://[/i] links just like you would use normal links. This works for links to other devonTHINK records, but also when embedding images.

Two examples:

link to document

image caption goes here


This should also work when linking to the .css stylesheet (see tip above).
2 Likes

To add: one thing that I haven’t figured out yet is file transclusion. See http://fletcher.github.io/MultiMarkdown-5/transclusion.html.

While part of MultiMarkdown, I haven’t been able to get it to work with DT-links.

Thanks Eeljen for these tips.

I can add one (although it might be quite well-known). Adding tables can be a pain in Markdown, but if you install the “Tables - Create from CSV” Service from Brett Terpstra then you can add a table using a simple CSV syntax, right-click it and run the service to create a Multimarkdown table.

The link is http://brettterpstra.com/2016/08/17/csv-to-multimarkdown-table-update/

I just wanted to thank the OP for sharing these tips. I am using Markdown more and was looking for some ideas on how to implement it better. These were extremely helpful.

Here is another tip - instead of putting to link to your CSS stylesheet add the link as part of the Multimarkdown metadata at the top of the file. For example:

Title: Name of file
CSS: /path/to/css_file.css

My guess is that this probably isn’t going to be possible in DTPO, but you could use DTPO to merge the individual .md files as you go or once you are done.