Code highlighting

  • Posted in : Read WP
  • menjeyn
    Participant

    Hi there,

    I just wanted to share with you how I’ve enabled code highlighting in my blog by leveraging the utilities provided by this theme.

    I wanted to embed code snippets without all the boilerplate: PRE and CODE elements, and the “prettyprint” class. I just wanted to put my code in a CODE element and set the language.

    I accomplished this with the following CSS and JS:
    http://pastebin.com/sWPQHVbU

    I wanted to use jQuery for the JS, but it wouldn’t be available by the time that my JS was executed. (Yes, I could’ve make the code execute on page load, but this code is simpler).

    Is there any chance that this could be integrated in the theme?

    Thanks!

    Mehmet S.
    Keymaster

    Hi, you can use syntax_prettify shortcode.

    [syntax_prettify linenums=""]Text here.[/syntax_prettify]
    

    linenums="linenums" … To show line numbers.

    See image:

    At live demo: http://themes.pixelwars.org/read-wp/typography/

    menjeyn
    Participant

    Thanks, Mehmet!

    Mehmet S.
    Keymaster

    You are welcome.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for the following item
Login and Registration Log in · Register