Default language for non-fenced code blocks

Filip Verhaeghe's Avatar

Filip Verhaeghe

29 Jan, 2014 01:23 PM

I wish I could provide at the start of the document, as metadata, the default language to use for non-fenced code blocks. The syntax highlighting consistently choose the wrong language. Fenced code blocks are not as nice as simple indentation when writing a document that contains lots and lots of code.

  1. Support Staff 1 Posted by Brett on 29 Jan, 2014 03:31 PM

    Brett's Avatar

    Due to the order in which the conversion happens and the fact that regular Markdown code blocks have no input for language specifier, this isn't feasible (as much as I would agree it would be a handy feature).

    For fenced code blocks I'm able to insert a language specifier prior to them being converted to code tags, and the conversion handles adding the class. With regular code blocks I have to wait until after the conversion has taken place, and injecting classes at that point would be difficult.

    I suppose I could handle it with JavaScript, parsing for any code blocks that don't have a class already and assigning one based on metadata before running the highlighter. That might work, although the highlighter has a habit of overriding the class anyway (which is a huge pain). I'll take a look at it, though.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac