neildaemond Posted December 4, 2011 Share Posted December 4, 2011 i wanted to use SyntaxHighlighter(http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html) on my page. The section of code to be highlighted should be wrapped with the <pre> tag, but also with a class like: <pre class="brush: js">code</pre> I know selecting the 'pre' format form the dropdox box will surround my text with <pre>, but is there a way to add more options to that dropbox which will also add the appropriate class? Thanks in advance, Link to comment Share on other sites More sharing options...
ryan Posted December 5, 2011 Share Posted December 5, 2011 There are a way to do it with TinyMCE only (using styleselect in the buttons1, using theme_advanced_styles and modifying TinyMCE content.css), but I think it's simpler just to apply it at render time in ProcessWire, like this: $page->body = str_replace("<pre>", "<pre class='brush: js'>", $page->body); You could do that before outputting your $page->body field. Link to comment Share on other sites More sharing options...
neildaemond Posted December 16, 2011 Author Share Posted December 16, 2011 A nice and simple solution! And I guess if I want to be able to select different 'brush' classes, then I'd have to go the way you mentioned... "(using styleselect in the buttons1, using theme_advanced_styles and modifying TinyMCE content.css)" I ended up just sticking with the basic <pre> tag, however... BUT, perhaps when I start blogging more about code, I'll look back into syntax highlighting.. and update this post with my results. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now