Documentation
¶
Overview ¶
Package pre provides constructors and methods for the HTML <pre> element.
The <pre> HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or monospaced font. Whitespace inside this element is displayed as written.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<pre") TagClose = []byte("</pre>") )
Byte constants for HTML rendering.
Functions ¶
func New ¶
New creates a new pre element with the given child nodes Example: pre.New(text.Text("Code")) Renders: <pre>Code</pre>
func RawText ¶
func RawText(content string) *element
RawText creates a new pre element with raw text content. Uses text.RawText which is not HTML-escaped. Example: pre.RawText("<code>var x = 1;</code>") Renders: <pre><code>var x = 1;</code></pre>
func RawTextf ¶
RawTextf creates a new pre element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: pre.RawTextf("<code>%s</code>", source) Renders: <pre><code>fmt.Println()</code></pre>
func Static ¶
func Static(content string) *element
Static creates a new pre element with static text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: pre.Static("func main() {}") Renders: <pre>func main() {}</pre>