Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add syntax highlighting to a WordPress blog hosted on WordPress.com?

I'd like to have a good syntax highlighter for my WordPress blog. What options do I have available? I often see one which has well-colored syntax highlighting and options to copy to the clipboard. Does anyone have an idea what tool this is?

like image 477
codingfloor Avatar asked Aug 13 '09 18:08

codingfloor


People also ask

How do I use syntax highlighter in WordPress?

To add a SyntaxHighlighter Code block to a post or page you click on the + icon at the left of any empty block or at the top left of the editor then search for SyntaxHighlighter and click on the SyntaxHighlighter Code icon. Paste the code into the block. Next select the code language from the block settings.

What is syntax highlighting in WordPress?

Syntax highlighting is a styling format commonly used to display code. It adds line numbers and colors to highlight code patterns which makes it easy to understand.

How do I use WordPress code syntax block?

When creating a new code block, select Code block, and then in the Inspector (Block Controls on the Right) select the language for the code. The code will not change within the editor, but you'll see a small label with the selected language.


1 Answers

On wordpress.com, you can't install plugins, so you have to use Wordpress' built-in widget.

Do it like:

[code language='python']  [/code] 

Note that those tags go inside your visual editor, not the HTML editor.

You can find more information here.

like image 123
samoz Avatar answered Sep 21 '22 13:09

samoz