HUGO
Menu
GitHub 90265 stars Mastodon

debug.VisualizeSpaces

Returns the given string with spaces and other whitespace characters replaced by visible placeholders.
Syntax
debug.VisualizeSpaces STRING
Returns
string

Usage

The debug.VisualizeSpaces function returns the given string with spaces and other whitespace characters replaced by visible placeholders. Use this function to find unexpected whitespace in a string.

The function replaces these characters:

CharacterPlaceholder
Space[SPACE]
Tab[TAB]
Newline[NEWLINE]
Carriage return[CR]
Vertical tab[VTAB]
Null[NUL]
Unicode replacement character (U+FFFD)[U+FFFD]

The [NEWLINE] placeholder is followed by the original newline, so each line of the input remains on its own line in the output.

Examples

{{ debug.VisualizeSpaces "foo  bar" }} → foo[SPACE][SPACE]bar
{{ debug.VisualizeSpaces "foo\tbar" }} → foo[TAB]bar