HtmlForgeX

API Reference

Class

PrismJsCodeBlock

Namespace HtmlForgeX
Assembly HtmlForgeX
Base Element

PrismJS syntax-highlighted code block with fluent API

Inheritance

Constructors

PrismJsCodeBlock 2 overloads
public PrismJsCodeBlock() #

Initializes a new PrismJS code block

public PrismJsCodeBlock(String code, PrismJsLanguage language = None) #

Initializes a new PrismJS code block with code content

Parameters

code System.String requiredposition: 0
language HtmlForgeX.PrismJsLanguage = None optionalposition: 1

Methods

public PrismJsCodeBlock AddCssClass(params String[] classes) #
Returns: PrismJsCodeBlock

Add custom CSS classes

Parameters

classes System.String[] requiredposition: 0
public PrismJsCodeBlock Bash() #
Returns: PrismJsCodeBlock

Set language to Bash

public PrismJsCodeBlock CSharp() #
Returns: PrismJsCodeBlock

Set language to C#

public PrismJsCodeBlock Css() #
Returns: PrismJsCodeBlock

Set language to CSS

public PrismJsCodeBlock DarkTheme() #
Returns: PrismJsCodeBlock

Use dark theme

public PrismJsCodeBlock EnableCopyButton(Boolean enable = true) #
Returns: PrismJsCodeBlock

Enable or disable copy to clipboard button

Parameters

enable System.Boolean = true optionalposition: 0
public PrismJsCodeBlock EnableLineNumbers(Boolean enable = true) #
Returns: PrismJsCodeBlock

Enable or disable line numbers

Parameters

enable System.Boolean = true optionalposition: 0
public PrismJsCodeBlock EnableWordWrap(Boolean enable = true) #
Returns: PrismJsCodeBlock

Enable word wrapping

Parameters

enable System.Boolean = true optionalposition: 0
EscapeHtml(System.String arg1) #

Escapes HTML characters in code content

Parameters

arg1 System.String required
GetLanguageClass() #

Gets the CSS class for the specified language

GetThemeLibrary() #

Gets the appropriate theme library enum for the current theme

public PrismJsCodeBlock GitHubTheme() #
Returns: PrismJsCodeBlock

Use GitHub theme

public PrismJsCodeBlock HighlightLine(params Int32[] lineNumbers) #
Returns: PrismJsCodeBlock

Highlight specific lines (1-based line numbers)

Parameters

lineNumbers System.Int32[] requiredposition: 0
public PrismJsCodeBlock Html() #
Returns: PrismJsCodeBlock

Set language to HTML

public PrismJsCodeBlock Java() #
Returns: PrismJsCodeBlock

Set language to Java

public PrismJsCodeBlock JavaScript() #
Returns: PrismJsCodeBlock

Set language to JavaScript

public PrismJsCodeBlock Json() #
Returns: PrismJsCodeBlock

Set language to JSON

public PrismJsCodeBlock OkaidiaTheme() #
Returns: PrismJsCodeBlock

Use Okaidia theme (popular dark theme)

public PrismJsCodeBlock Php() #
Returns: PrismJsCodeBlock

Set language to PHP

public PrismJsCodeBlock PowerShell() #
Returns: PrismJsCodeBlock

Set language to PowerShell

public PrismJsCodeBlock Python() #
Returns: PrismJsCodeBlock

Set language to Python

RegisterLibraries() #

Registers the PrismJS library and theme-specific resources

RegisterThemeLibrary() #

Registers theme-specific library resources

public PrismJsCodeBlock SetCode(String code) #
Returns: PrismJsCodeBlock

Set the code content

Parameters

code System.String requiredposition: 0
public PrismJsCodeBlock SetLanguage(PrismJsLanguage language) #
Returns: PrismJsCodeBlock

Set the programming language for syntax highlighting

Parameters

language HtmlForgeX.PrismJsLanguage requiredposition: 0
public PrismJsCodeBlock SetMaxHeight(String height) #
Returns: PrismJsCodeBlock

Set maximum height with scrolling

Parameters

height System.String requiredposition: 0
public PrismJsCodeBlock SetStartLineNumber(Int32 startLine) #
Returns: PrismJsCodeBlock

Set the starting line number

Parameters

startLine System.Int32 requiredposition: 0
public PrismJsCodeBlock SetTheme(PrismJsTheme theme) #
Returns: PrismJsCodeBlock

Set the theme for syntax highlighting

Parameters

theme HtmlForgeX.PrismJsTheme requiredposition: 0
public PrismJsCodeBlock SetTitle(String title) #
Returns: PrismJsCodeBlock

Set a title/caption for the code block

Parameters

title System.String requiredposition: 0
public PrismJsCodeBlock Sql() #
Returns: PrismJsCodeBlock

Set language to SQL

public PrismJsCodeBlock TomorrowNightTheme() #
Returns: PrismJsCodeBlock

Use Tomorrow Night theme

public override String ToString() #
Returns: String

Builds the HTML for the PrismJS code block

public PrismJsCodeBlock TypeScript() #
Returns: PrismJsCodeBlock

Set language to TypeScript

public PrismJsCodeBlock VsTheme() #
Returns: PrismJsCodeBlock

Use VS theme (Visual Studio)

Properties

public PrismJsLanguage Language { get; set; } #

Programming language for syntax highlighting

public PrismJsTheme Theme { get; set; } #

Theme for syntax highlighting

public String Code { get; set; } #

Code content to highlight

public String Title { get; set; } #

Optional title/caption for the code block

public Boolean ShowLineNumbers { get; set; } #

Enable line numbers

public Boolean ShowCopyButton { get; set; } #

Enable copy to clipboard button

public List<Int32> HighlightLines { get; set; } #

Highlight specific lines (1-based)

public Int32 StartLineNumber { get; set; } #

Starting line number (default: 1)

public String MaxHeight { get; set; } #

Maximum height of the code block

public Boolean WordWrap { get; set; } #

Enable word wrap

public List<String> CssClasses { get; set; } #

Custom CSS classes