Documentation ¶
Overview ¶
Package splash adds a dash of color to embedded source code in HTML
Index ¶
- func AddCSSToHTML(htmlData, cssData []byte) ([]byte, error)
- func Highlight(htmlData []byte, styleName string, unescape bool) ([]byte, []byte, error)
- func SetDefaultLanguage(languageName string)
- func Splash(htmlData []byte, styleName string) ([]byte, error)
- func UnescapeSplash(htmlData []byte, styleName string) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCSSToHTML ¶
AddCSSToHTML takes htmlData and adds cssData in a <style> tag. Returns an error if </head> or <html> does not already exists. Tries to add CSS as late in <head> as possible.
func Highlight ¶
Highlight takes HTML code as bytes and tries to syntax highlight code between <pre> and </pre> tags.
"style" is a syntax highlight style, like "monokai".
Full style list here: https://github.com/alecthomas/chroma/tree/master/styles
Returns the modified HTML source code and CSS style.
unescape can be set to true for unescaping already escaped code in <pre> tags, which can be useful when highlighting code in newly rendered markdown.
func SetDefaultLanguage ¶
func SetDefaultLanguage(languageName string)
SetDefaultLanguage changes the default language from "shell" to something else. Must be supported by chroma.
func Splash ¶
Splash takes HTML code as bytes and tries to syntax highlight code between <pre> and </pre> tags.
"style" is a syntax highlight style, like "monokai".
Full style list here: https://github.com/alecthomas/chroma/tree/master/styles
Returns the modified HTML source code with embedded CSS as a <style> tag. Requires the given HTML to contain </head> or <html>.
language specifiers like <code class="language-c"> are supported.
func UnescapeSplash ¶
UnescapeSplash does the same as Splash, but unescapes the HTML in the source code before highlighting. Use this if "&" appears in the highlighted code instead of "&", and that is not what you wanted. Useful when highlighting source code after having rendered Markdown.
Types ¶
This section is empty.