Posting Source Code on WordPress.com

To post some syntax highlighting code on WordPress.com, you should switch to Text mode and then only need to surround it with code-block like so:

[code]
    your code here
[/code]

The following is directly copied from the documentation page [1]:

  • autolinks (true/false) — Makes all URLs in your posted code clickable.
  • collapse (true/false) — If true, the code box will be collapsed when the page loads, requiring the visitor to click to expand it. Good for large code posts.
  • firstline (number) — Use this to change what number the line numbering starts at. It defaults to 1.
  • gutter (true/false) — If false, the line numbering on the left side will be hidden.
  • highlight (comma-seperated list of numbers) — You can list the line numbers you want to be highlighted. For example “4,7,19”.
  • htmlscript (true/false) — If true, any HTML/XML in your code will be highlighted. This is useful when you are mixing code into HTML, such as PHP inside of HTML. Only work with certain code languages.
  • light (true/false) — If true, the gutter (line numbering) and margin (see below) will be hidden. This is helpful when posting only one or two lines of code.
  • padlinenumbers (true/false/integer) — Allows you to control the line number padding. true will result in automatic padding, false will result in no padding, and entering a number will force a specific amount of padding.
  • title (string) — Set a label for your code block. Can be useful when combined with the collapse parameter.
  • language (string) — Set the language for syntax highlight of the code block. Default to text
actionscript3
bash
clojure
coldfusion
cpp
csharp
css
delphi
diff
erlang
fsharp
go
groovy
html
java
javafx
javascript
latex (you can also render LaTeX)
matlab (keywords only)
objc
perl
php
powershell
python
r
ruby
scala
sql
text
vb
xml

 

Reference:

[1] WordPress.com. Posting Source Code. Retrieved June 09, 2018, from https://en.support.wordpress.com/code/posting-source-code/

Advertisements