Evotec

Project

PSWriteHTML

PSWriteHTML is an open-source PowerShell project with packages, release history, and working documentation.

Stars 995
Forks 114
Open issues 69
PowerShell Gallery downloads 7,436,513
Release v1.41.0
Language: PowerShell Updated: 2026-04-11

API Reference

Function

New-HTMLCodeBlock

Namespace PSWriteHTML

Creates a new HTML code block with customizable settings for syntax highlighting.

Remarks

This function creates a new HTML code block with customizable settings for syntax highlighting. It allows you to specify the code language, theme, group, title, line numbers visibility, highlighted lines, and line numbering offset.

Examples

Authored help example

EXAMPLE 1


New-HTMLCodeBlock -Code "function greet() { return 'Hello, World!'; }" -Style 'javascript' -Theme 'monokai' -Group 'Functions' -Title 'Greeting Function' -Highlight 2,4-6 -ShowLineNumbers $true -LineOffset 1
        

Creates a new HTML code block displaying a JavaScript function with a custom theme, belonging to the 'Functions' group, titled 'Greeting Function', highlighting lines 2, 4 to 6, showing line numbers, and starting line numbering from 1.

EXAMPLE 2


New-HTMLCodeBlock -Code "for ($i = 0; $i -lt 5; $i++) { Write-Host $i }" -Style 'powershell' -Group 'Loops' -Title 'For Loop Example' -ShowLineNumbers $false
        

Creates a new HTML code block displaying a PowerShell for loop without line numbers, belonging to the 'Loops' group, titled 'For Loop Example'.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

New-HTMLCodeBlock -Code <String> [-Group <String>] [-Highlight <String[]>] [-LineOffset <String>] [-ShowLineNumbers <Nullable`1>] [-Style <assembly>] [-Theme <enlighter>] [-Title <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Parameters

Code String requiredposition: 0pipeline: False
Specifies the code content to be displayed in the code block.
Group String optionalposition: 3pipeline: False
Specifies the group to which the code block belongs.
Highlight String[] optionalposition: 5pipeline: False
Specifies specific lines to highlight in the code block.
LineOffset String optionalposition: 7pipeline: False
Specifies the starting line number offset for line numbering.
ShowLineNumbers Nullable`1 optionalposition: 6pipeline: False
Indicates whether line numbers should be displayed in the code block.
Style String optionalposition: 1pipeline: Falsevalues: 59
Specifies the language style for syntax highlighting. Default is 'powershell'.
Possible values: assembly, asm, avrassembly, avrasm, c, cpp, c++, csharp, css, cython, cordpro, diff, docker, dockerfile, generic, standard, groovy, go, golang, html, ini, conf, java, js, javascript, jquery, mootools, ext.js, json, kotlin, less, lua, gfm, md, markdown, octave, matlab, nsis, php, powershell, prolog, py, python, raw, ruby, rust, scss, sass, shell, bash, sql, squirrel, swift, typescript, vhdl, visualbasic, vb, xml, yaml
Theme String optionalposition: 2pipeline: Falsevalues: 13
Specifies the theme for the code block. Available themes include 'enlighter', 'beyond', 'classic', and more.
Possible values: enlighter, beyond, classic, godzilla, atomic, droide, minimal, eclipse, mowtwo, rowhammer, bootstrap4, dracula, monokai
Title String optionalposition: 4pipeline: False
Specifies the title of the code block.