Background
Unfortunately, people with good intentions still lag trying to share code snippets via WordPress.
HTML
Code Block
If we use the pre-tag, here is how it plays out.
Powershell
Code Image
Code Output
#Get Current Windows User
#$currentUserObj = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name;
$currentUserObj = (whoami);
#Split User into array
$currentUserArray = $currentUserObj.Split("\");
#Get second array user
$currentUserName = $currentUserArray[1];
#Prepare Output
$log = "Hello {0}" -f $currentUsername
#Display Output
Write-Output $log
WordPress
Code Block
The code block should be enclosed in a code tag.
Syntax
Options
Supported Languages
Supported Parameters
There are a few configurable parameters that one can use to customize the output.
Thankfully, they are all optional.
Option | Description |
---|---|
autolinks | (true/false) — Makes all URLs in your posted code clickable. Defaults to true. |
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. Defaults to false. |
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. Defaults to true. highlight (comma-separated 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. Defaults to false and will 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. Defaults to false. |
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. |
Sample
SQL
Code Image
Code Output
select tblKJV.* from public.kjv tblKJV limit 5
Powershell
Code Image
Code Output
#Get Current Windows User #$currentUserObj = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name; $currentUserObj = (whoami); #Split User into array $currentUserArray = $currentUserObj.Split("\"); #Get second array user $currentUserName = $currentUserArray[1]; #Prepare Output $log = "Hello {0}" -f $currentUsername #Display Output Write-Output $log
Dedicated
In dedication to one of the great ones, Alex Gorbatchev.
His syntax highlighting code is the basis of WordPress’s implementation.
Please see more here:-
- GitHub
- syntaxhighlighter/syntaxhighlighter
Link
- syntaxhighlighter/syntaxhighlighter
References
- WordPress
- Support – WordPress
- Blocks »SyntaxHighlighter Code Block
Link
- Blocks »SyntaxHighlighter Code Block
- Support – WordPress