Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a self-hosted WP install, and have been using codecolorer (and have tried a few others along the way) to highlight R syntax. Looks nice, too.

The problem is that R uses a <- symbol instead of = when assigning objects (on pretty much every single line), and when you switch from 'Visual' to 'HTML' while editing a post it will mangle the code - <- becomes &lt;-; worse, sections of the code will disappear.

It would be possible to use = for the 'assign' command but it's not, strictly-speaking, correct. At the moment I have to do all the pretty writing and inserting of images in WYSIWYG 'visual' mode, then switch to HTML just before I post to fix up the R code, and then be careful never to switch back again. Ever.

Any fixes for this behaviour?

EDIT: examples! Putting this into the Visual editor:

[cc]
lorum <- ipsum
[/cc]

Produces the following in the final post:

lorum &lt;- ipsum

Going back to HTML mode and putting a <- code worked for the final post but then I could never switch back to Visual without the < being interpreted as part of a tag.

share|improve this question
    
Have you tried wrapping those chunks in <code></code>? –  SickHippie Mar 22 '12 at 16:09
    
Yep - they're all wrapped nicely. <code lang="rsplus"></code>. –  Simbamangu Mar 22 '12 at 18:13
1  
I found some sample R code and pasted it into the WP editor. I switched back and forth between Visual and HTML mode with no ill effects. The transliteration of '<' into '&lt;' is supposed to happen. The '<' character has special meaning as a start-of-tag in HTML, so it must be escaped into the '&lt;' entity to show up correctly in text. Were you by chance changing it back to a '<' while in HTML mode? Because that would wreak havoc on your post. –  Dougal Campbell Mar 22 '12 at 21:08
    
The only way to make '&lt' not appear in the post within the code was to put it in while in HTML mode - try 'preview' to see what I mean. Indeed, that's why it gets mangled twixt Visual and HTML ... –  Simbamangu Mar 23 '12 at 6:33
    
Okay, you've edited with more details... When you switch to HTML editor, DO NOT change '&lt;' back to '<'. This is what is causing your problems. Leave it alone. It's doing what it's supposed to do. –  Dougal Campbell Mar 24 '12 at 2:41
show 3 more comments

1 Answer

Solved it. A real RTFM moment.

The FAQ for CodeColorer makes a note about this (though it's not mentioned in the main how-to text).

Using the escaped = "true" code in the [cc] tag brings back the behaviour I was looking for – now it's possible to write the <- operator in Visual (and it becomes &lt in HTML), but the published post displays <- correctly.

Thus, entering this in the visual editor:

[cc escaped="true"]
lorum <- ipsum
[/cc]

Produces, in the published post:

lorum <- ipsum
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.