# New-HTMLCodeBlock

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

Project

PSWriteHTML

Generate HTML reports, dashboards, and emails from PowerShell without writing HTML, CSS, or JavaScript.

[View on GitHub](https://github.com/EvotecIT/PSWriteHTML) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteHTML/releases/tag/v1.41.0) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteHTML/1.40.0)

Stars **1,025**

Forks **114**

Open issues 

PowerShell Gallery downloads **7,576,901**

Release **v1.45.0**

Language: PowerShell Updated: 2026-11-19

Command 

**Module**

`PSWriteHTML`

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

## Syntax

```
New-HTMLCodeBlock
[-Code] <String>
[[-Group] <String>]
[[-Highlight] <String[]>]
[[-LineOffset] <String>]
[[-ShowLineNumbers] <Nullable`1>]
[[-Style] <String>]
[[-Theme] <String>]
[[-Title] <String>]
[<CommonParameters>]
```

[#](#method-new-htmlcodeblock-string-string-string-string-nullable-string-string-string)

Parameter set: `All Parameter Sets`

## Description

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

### Example 1

```powershell
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

```powershell
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'.

## Parameters

**-Code String requiredposition: 0**

Specifies the code content to be displayed in the code block.

**-Group String optionalposition: 3**

Specifies the group to which the code block belongs.

**-Highlight String[] optionalposition: 5**

Specifies specific lines to highlight in the code block.

**-LineOffset String optionalposition: 7**

Specifies the starting line number offset for line numbering.

**-ShowLineNumbers Nullable<T> optionalposition: 6**

Indicates whether line numbers should be displayed in the code block.

**-Style String optionalposition: 1**

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: 2**

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: 4**

Specifies the title of the code block.

## 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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:B7A1BEDCB7D7213A847A5B43075D7E4B0068A064DAF3111D1D90EE980ECB5905 -->
