Correction (solution and workaround): using the "Prevent formatting" syntax inside the code environment solves the problem. It would be reasonable for the next version of SyntaxLove to do this automatically for the whole code, i.e. to replace this

Modification

I think this plugin is great, but the current SyntaxHighlighter in Syntaxlove is a little dated. So I created a package for personal use based on the latest SyntaxHighlighter fork from "outofwhatbox.com". I noticed that there are a lot of options that can't even be touched with this PmWiki plugin, so I went ahead and modified the main PHP script to default to "Plain" if no code type is defined, and I also added access to all of the options: turning off numbers, adding titles, turn off wrapping, turn on collapsing, etc. I am certain this can be done more eloquently, but I wanted more flexibility, and it wasn't currently there, so I added it in my personal copy. It would be nice if something like this was added by default to Syntaxlove. I stink at regular expression, so I am sure this can really be improved upon.

Note: code type must always be specified first; I wanted to keep it compatible with current syntax, and I didn't want to loop more than I had to to find it, so it is always first. Technically, you could give the code its own setting ID like code='php'. Then you could have this recipe find the code anywhere.

example use:

(:codestart:)Plain style(:codeend:)

(:codestart php title='Title' highlight='[1,2,3,7]' wrap='false':)

Use PHP styling.

Add the title "Title"

highlight lines 1,2,3, and 7

turn line wrapping off

(:codeend:)

This is the modification I made to the Syntaxlove.php for use with the latest SyntaxHighlighter:

I removed all old Syntaxhighlighter files and replaced them with the latest from outofwhatbox.com.

I remapped the shCore.css to look for the images in the correct place

I then modified syntaxlove.php to use all options and default to plain style if none is specified

Limit display

Is it possible to limit the number of lines displayed?

Thanks for the great recipe.

Steven

Hello Steve, do you mean to toggle on or off the line numbers? If yes, I still haven't found a workaround in the actual version of the recipe, but found an alternative solution under [(approve links)editdiff]. I will look, if I can implement this feature in a future version of this recipe.

Problematic interactions with quoted-printable encoding

Great recipe :) I have just installed it, and one of the first source snippets I was working with logs using HTML strings. Some of these strings include quoted-printable encoding, e.g. &amp;. The rendered output displays "&" rather than "&amp;", as does clicking on SyntaxHighlighter's "view source" button (not the browser's "view source"!). In short the rendered source is not the contents of the codestart...codeend block verbatim.

I have produced an example test case that can expose a variety of potential encoding errors:

The current version (20090920) displays the second to last "puts" line as

puts "<p>Evil HTML output < &</p>"

rather than the expected

puts "<p>Evil HTML output &lt; &amp;</p>"

One reason this is important is that is should be possible for a scripting language to extract and run code from an HTML page. To do this one would extract the contents of <pre> or <code> blocks, remove the quoted-printable encoding, and eval() the resulting text as a script. If the output (as displayed in a web browser) is not a faithful representation of the input (the exact content of the codestart...codeend block) then this becomes impossible.

Recommended fix: change the Markup() call at the bottom of syntaxlove.php to the following:

Thanks Twylite, your fixed markup is welcome. Without this fix you can not use SyntaxLove for most languages. The worst issue with the old markup: It generates closing tags for XML which are not given in the plain code - and that is really annoying. Example:

<xml version="1.0" encoding="ISO-8859-1"?>

Try to highlight this code line with SyntaxLove (current download version) and you know whats the problem.

Hello DaveG, thanks for using my recipe. I already thought about such a markup as you mentioned above, but I can't (or won't) remember the markup for such special things in Ruby. I will look, if your markup works correct and then include the changes in the recipe

Language Inclusion Options

Nice script. Given that inclusion of all languages is over 90k of javascript to download, even if it's only the first time, do you plan on incorporating a way to include/exclude languages? Perhaps a simple true/false array would work, with a default set for all?

DaveG, 31-Aug-2009

Hello DaveG, glad you like it. I must say that I doesn't take a look at the overhead if I load all languages. The option with the array you mention will easy to integrate. In the next few days I will do it and upload a new version