Drafts 5.9 (iOS) Released

Drafts 5.9 (iOS) is now available in the App Store, details below.

  • New: setAllSort(sortBy, sortDescending, sortFlaggedToTop) method on Workspace script object.
  • New: Fenced code blocks (```) will be highlighted in monospace font in MultiMarkdown and GitHub Markdown syntaxes. Also posted two new action examples which make good additions to a Markdown keyboard if you work with inline or code blocks:
    • Inline code: Wraps selection in back-ticks as inline code, or inserts back-tick if no selection.
    • Code Block: Wraps selection in triple back-ticks as code block, or inserts triple back-tick if no selection.
  • Fix: Sync sometime would not fail to properly update other devices when a draft was move archived/trashed.

For a complete history of updates, visit the changelog

Fenced code blocks do not appear to be working for me. I used the Code Block action to make sure there wasn’t some character issue. There is a portion that is monospace, but I think that is just due to being indented.

Do you have MultiMarkdown or GitHub Markdown syntax selected for the Draft? Regular Markdown does not have fenced blocks, they are an extension to the syntax.

Hi,

It didn’t work for me either, I tried in MultiMarkdown and Github Markdown for both my current drafts and all by default and neither worked.

Thanks a lot for your hard work !

Cheers

That appears to be working. The code block is in monospace font. That is the only formatting applied to a code block.

How it was you mean by higlighted ? I though I’ll have some code colouring syntax

Try to use a preview action:)

Well, it’s “syntax highlighting”. So any change to the text based on it’s content is part of the highlighting process. Sorry for lack of clarity.

I got excited with the fenced code blocks. Then found out that it doesn’t do syntax highlighting. I hope that it will become a feature sometime in the future.

1 Like

While syntax highlighting would be nice all that ‘fenced code blocks’ (three backticks) implies is monospace - so it’s readable.

However, I believe there is syntax in some flavours to suggest what language the code block is in. But that is a separate function.

Oh ok, I misunderstood ! Do you have any plan to add some colouring depending on the code in fenced code block ?

Yep doesn’t have any code colouring in this case, maybe I’m missing somethings

For showing it in a preview, you just have to configure your preview to use an existing syntax highlighter.

For example, if we take some Markdown with a code block containing some HTML and some Javascript like this…

… and then use a custom preview action such as this (just a standard Drafts Preview action step that I added a couple of syntax highlighter enabling lines to), you could get a syntax highlighted preview like this…

End of the day, live syntax highlighting is non-trivial, and setting it to work with potentially multiple languages inside multiple code blocks; well, since Drafts isn’t a full on IDE, I’d say that may be overkill, or at least well down the road on the application’s road map.

Anyway, hope the preview action option might be of some use.