WordPress.org

Forums

WP-Markdown
Code fences with syntax highlighting (8 posts)

  1. Dru89
    Member
    Posted 3 years ago #

    Is there any implementation of code fencing with this plugin?

    I noticed that you have code fences. Something like this:

    `
    Put code here.
    `

    But it doesn't seem to have any syntax highlighting associated with it. Any chance that there's a way to add a hint for what syntax it should be? I know I can just indent everything, but it looks like it has to be indented 8 spaces, and that can just get annoying.

    Something like

    `ruby
    if ruby_code? then "highlight like ruby"
    `

    or

    `java
    if (this.isJavaCode()) {
    return "highlight like java"
    }
    `

    would be preferable, if it existed. Maybe I'm just missing something?

    http://wordpress.org/extend/plugins/wp-markdown/

  2. Dru89
    Member
    Posted 3 years ago #

    Those backticks didn't quite show up as planned. Each line should be three back-ticks.

  3. Stanislav Khromov
    Member
    Posted 3 years ago #

    Hey Dru89,

    You can achieve this in the following way:

    - Install the following plugins:
    http://wordpress.org/extend/plugins/syntaxhighlighter/
    http://wordpress.org/extend/plugins/wp-markdown-syntaxhighlighter/

    - Disable the built-in syntax highlighter in WP-Markdown
    (Settings -> Writing -> Enable Prettify syntax highlighter: Off )

    Now you can prefix your code with the language on the first line, like this:
    #!ruby
    (your code here)

  4. jkratz
    Member
    Posted 3 years ago #

    Not working for me. If I save a draft the following happens:

    #!ruby
    class Foo < Bar
      def hello
        puts "Hello World!"
      end
    end

    turns into:
    # !ruby

    class Foo < Bar def hello puts "Hello World!" end end

  5. jkratz
    Member
    Posted 3 years ago #

    I have the syntax highlighting evolved plugin, wp markdown, and the plugin that links them up. also turned off the Prettify support in wp_markdown. any ideas? running 3.5.1 of WP at Dreamhost.

  6. jkratz
    Member
    Posted 3 years ago #

    I also tried putting the new php markdown extra in there. no luck.

  7. Stanislav Khromov
    Member
    Posted 3 years ago #

    @jkrats

    Can you try using the "Code sample" button in the editor instead of backticks?

    It looks like this:
    { }

  8. jkratz
    Member
    Posted 3 years ago #

    @khromov

    Thanks. my bad. I just put the text in the example. Didn't even think about using that button first.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Markdown
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic