2

Is it possible to format code in the wysiwyg editor, up to now I use Blockquotes to represent code, but my problem is that it does automatically line breaks, and I don't want to have random line breaks in my code.

3

There are several ways to deal with this problem.

You could have a look for some syntax highlighter plugin, those will also bring you coloured text with highlighted keywords etc. pp. This is probably nice, if you use code quite often. I use SyntaxHighlighter Evolved.

If you want to do this by hand, <code> is probably the HTML-element you want to use, just like Stack Overflow does, too. It´s "designed" to be used that way (and understood as code from a semantical view, too).

If you want to prevent line breaks, you can add this to your CSS:

code { white-space: nowrap; }

You have to use this in the text view of the editor though, as the WYSIWYG version would probably strap it out.

You can get around that by defining a shortcode for your code-tag. You will find lots of examples for that around the web.

  • Thanks for your answer. Can you provide a syntax highlighter plugin that matches my requirements? – bpoiss Jan 17 '16 at 13:55
  • I updated my post, there you´ll find a link to SyntaxHighlighter Evolved, that´s the plugin I use. – flomei Jan 17 '16 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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