WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Dru89
    Member
    Posted 1 year 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 1 year ago #

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

  3. khromov
    Member
    Posted 1 year 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 1 year 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 1 year 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 1 year ago #

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

  7. khromov
    Member
    Posted 1 year ago #

    @jkrats

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

    It looks like this:
    { }

  8. jkratz
    Member
    Posted 1 year 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

About this Topic