ansi

package
v0.0.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ansi provides for converting text containing ansi color codes to be rendered in LaTeX format to enable the decorated ansi text to be displayed in a GitHub README.md document.

Index

Constants

View Source
const (
	LaTeXOff       = `}}`
	LaTeXBold      = `{\bf{`
	LaTeXItalic    = `{\emph{`
	LaTeXDim       = "{{" // Not implemented by GitHub.
	LaTeXUnderline = "{{" // Not implemented by GitHub.
	LaTeXBlink     = "{{" // Not implemented by GitHub.
	LaTeXReverse   = "{{" // Not implemented by GitHub.
	LateXHidden    = "{{" // Not implemented by GitHub.
	LaTeXStrikeout = "{{" // Not implemented by GitHub.

	LaTeXBlack   = `{\color{black}{`
	LaTeXRed     = `{\color{red}{`
	LaTeXGreen   = `{\color{green}{`
	LaTeXYellow  = `{\color{yellow}{`
	LaTeXBlue    = `{\color{blue}{`
	LaTeXMagenta = `{\color{magenta}{`
	LaTeXCyan    = `{\color{cyan}{`
	LaTeXWhite   = `{\color{white}{`

	LaTeXHiBlack   = LaTeXBlack   // Not implemented by GitHub.
	LaTeXHiRed     = LaTeXRed     // Not implemented by GitHub.
	LaTeXHiGreen   = LaTeXGreen   // Not implemented by GitHub.
	LaTeXHiYellow  = LaTeXYellow  // Not implemented by GitHub.
	LaTeXHiBlue    = LaTeXBlue    // Not implemented by GitHub.
	LaTeXHiMagenta = LaTeXMagenta // Not implemented by GitHub.
	LaTeXHiCyan    = LaTeXCyan    // Not implemented by GitHub.
	LaTeXHiWhite   = LaTeXWhite   // Not implemented by GitHub.

	LaTeXBkBlack   = LaTeXBlack   // Not implemented by GitHub.
	LaTeXBkRed     = LaTeXRed     // Not implemented by GitHub.
	LaTeXBkGreen   = LaTeXGreen   // Not implemented by GitHub.
	LaTeXBkYellow  = LaTeXYellow  // Not implemented by GitHub.
	LaTeXBkBlue    = LaTeXBlue    // Not implemented by GitHub.
	LaTeXBkMagenta = LaTeXMagenta // Not implemented by GitHub.
	LaTeXBkCyan    = LaTeXCyan    // Not implemented by GitHub.
	LaTeXBkWhite   = LaTeXWhite   // Not implemented by GitHub.

	LaTeXBkHiBlack   = LaTeXBkBlack   // Not implemented by GitHub.
	LaTeXBkHiRed     = LaTeXBkRed     // Not implemented by GitHub.
	LaTeXBkHiGreen   = LaTeXBkGreen   // Not implemented by GitHub.
	LaTeXBkHiYellow  = LaTeXBkYellow  // Not implemented by GitHub.
	LaTeXBkHiBlue    = LaTeXBkBlue    // Not implemented by GitHub.
	LaTeXBkHiMagenta = LaTeXBkMagenta // Not implemented by GitHub.
	LaTeXBkHiCyan    = LaTeXBkCyan    // Not implemented by GitHub.
	LaTeXBkHiWhite   = LaTeXBkWhite   // Not implemented by GitHub.

)

GitHub LaTeX supported color/style codes.

View Source
const (
	Off          = "\x1b[0m"
	Bold         = "\x1b[1m"
	Dim          = "\x1b[2m"
	BoldDimOff   = "\x1b[22m"
	Italic       = "\x1b[3m"
	ItalicOff    = "\x1b[23m"
	Underline    = "\x1b[4m"
	UnderlineOff = "\x1b[24m"
	Blink        = "\x1b[5m"
	BlinkOff     = "\x1b[25m"
	Reverse      = "\x1b[7m"
	ReverseOff   = "\x1b[27m"
	Hidden       = "\x1b[8m"
	HiddenOff    = "\x1b[28m"
	Strikeout    = "\x1b[9m"
	StrikeoutOff = "\x1b[29m"

	// Basic foreground colors.
	Black   = "\x1b[30m"
	Red     = "\x1b[31m"
	Green   = "\x1b[32m"
	Yellow  = "\x1b[33m"
	Blue    = "\x1b[34m"
	Magenta = "\x1b[35m"
	Cyan    = "\x1b[36m"
	White   = "\x1b[37m"

	// Bright (intense) foreground colors.
	HiBlack   = "\x1b[90m"
	HiRed     = "\x1b[91m"
	HiGreen   = "\x1b[92m"
	HiYellow  = "\x1b[93m"
	HiBlue    = "\x1b[94m"
	HiMagenta = "\x1b[95m"
	HiCyan    = "\x1b[96m"
	HiWhite   = "\x1b[97m"

	// Basic background colors.
	BkBlack   = "\x1b[40m"
	BkRed     = "\x1b[41m"
	BkGreen   = "\x1b[42m"
	BkYellow  = "\x1b[43m"
	BkBlue    = "\x1b[44m"
	BkMagenta = "\x1b[45m"
	BkCyan    = "\x1b[46m"
	BkWhite   = "\x1b[47m"

	// Bright (intense) background colors.
	BkHiBlack   = "\x1b[100m"
	BkHiRed     = "\x1b[101m"
	BkHiGreen   = "\x1b[102m"
	BkHiYellow  = "\x1b[103m"
	BkHiBlue    = "\x1b[104m"
	BkHiMagenta = "\x1b[105m"
	BkHiCyan    = "\x1b[106m"
	BkHiWhite   = "\x1b[107m"
)

ANSI terminal color/style escape codes.

View Source
const (
	// TabSpaces need to be converted to hard spaces.
	TabSpaces = "    "
	// HardSpace is using a no break space \u00A0 with a "Combining Grapheme
	// Joiner" \u034F which has no visible display but prevents GitHub's LaTeX
	// from merging consecutive spaces.  Two in a row is the same width as a
	// fixed LaTeX font character.
	HardSpace = " ͏ ͏" //
	// HardUnderscore is using a no break space \u00A0 with a "Combining Low
	// Line" \u0332 to simulate an underscore which GitHub LaTeX only permits
	// in math mode. Two in a row is the same width as a fixed LaTeX font
	// character.
	HardUnderscore = " ̲ ̲"
	// HardPercent is using a "SMALL PERCENT SIGN" \uFE6A in place of a
	// regular percent sign GitHub markdown processes normal percent signs.
	HardPercent = "﹪"
	// Dashes replacing hyphens with an 'FIGURE DASH' u2012 as a regular
	// hyphen in LaTeX is too short (compared to a = used in the
	// corresponding '=== RUN' test bracket.)
	Dashes = "\u2012\u2012\u2012"
)

Variables

This section is empty.

Functions

func Colorize

func Colorize(raw string, colorIt bool) string

Colorize either removes or converts ansi colors into LaTeX text to be displayed properly in a GitHub README.md file.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL