Documentation
¶
Index ¶
- Constants
- func DetectChromaLexerByFileName(fileName, fileLang string) chroma.Lexer
- func RenderCodeByLexer(lexer chroma.Lexer, code string) template.HTML
- func RenderCodeSlowGuess(fileName, language, code string) (output template.HTML, lexer chroma.Lexer, lexerDisplayName string)
- func RenderFullFile(fileName, language string, code []byte) ([]template.HTML, string)
- func UnsafeSplitHighlightedLines(code template.HTML) (ret [][]byte)
Constants ¶
const (
LanguagePlaintext = "plaintext"
)
Variables ¶
This section is empty.
Functions ¶
func DetectChromaLexerByFileName ¶ added in v1.26.0
func RenderCodeByLexer ¶ added in v1.26.0
RenderCodeByLexer returns a HTML version of code string with chroma syntax highlighting classes
func RenderCodeSlowGuess ¶ added in v1.26.0
func RenderCodeSlowGuess(fileName, language, code string) (output template.HTML, lexer chroma.Lexer, lexerDisplayName string)
RenderCodeSlowGuess tries to get a lexer by file name and language first, if not found, it will try to guess the lexer by code content, which is slow (more than several hundreds of milliseconds).
func RenderFullFile ¶ added in v1.26.0
RenderFullFile returns a slice of chroma syntax highlighted HTML lines of code and the matched lexer name
func UnsafeSplitHighlightedLines ¶ added in v1.26.0
UnsafeSplitHighlightedLines splits highlighted code into lines preserving HTML tags It always includes '\n', '\n' can appear at the end of each line or in the middle of HTML tags The '\n' is necessary for copying code from web UI to preserve original code lines ATTENTION: It uses the unsafe conversion between string and []byte for performance reason DO NOT make any modification to the returned [][]byte slice items
Types ¶
This section is empty.