Alternative Code Syntax + Highlighting

Nick Rowe's Avatar

Nick Rowe

04 Oct, 2011 12:14 AM

Can Marked support something like:

bash ./todo.rb buy tomato seeds ./todo.rb buy a new green hose ./todo.rb buy potting soil ./todo.rb plant tomatoes

where at least the code appears on different lines and maybe is able to highlight using bash syntax?

  1. Support Staff 1 Posted by Brett on 04 Oct, 2011 12:24 AM

    Brett's Avatar

    Hi Nick,

    I don't plan to support syntax highlighting directly, but with the right ruby gems you can concoct a script that runs through Pygments to use as a custom processor. I'll try to track down more info if you're interested in going that route.

    Also, MultiMarkdown 3 doesn't support the "fenced" code syntax you're using, but if you indent the whole block 5 or more spaces (or one tab) it will render as a `<pre><code>` block for you.

  2. 2 Posted by Nicholas Rowe on 04 Oct, 2011 12:34 AM

    Nicholas Rowe's Avatar

    Brett-

    Thanks- I really appreciate the quick reply. Can you tell me more
    about custom processors through Pygments? I want to use Marked to
    preview my blog entries before they go into jekyll. This means that
    seeing code highlighting would really help me out.

    -Nick

  3. Support Staff 3 Posted by Brett on 04 Oct, 2011 12:52 AM

    Brett's Avatar

    There's a good article on the RedCarpet repo on Github: https://github.com/tanoku/redcarpet

    If you simply make a script that accepts Markdown text on STDIN and returns rendered HTML on STDOUT, you can set the full UNIX path to the script as the custom processor in Marked preferences. It takes some fiddling, but it works. I don't have a working example of code highlighting for you, though. Someone made a Ruby script for it a while back but I've lost track of it. If I can find it, I'll post it here.

  4. Support Staff 4 Posted by Brett on 14 Oct, 2011 01:10 PM

    Brett's Avatar
  5. Brett closed this discussion on 14 Oct, 2011 01:10 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? 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