mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-09 10:47:05 +00:00
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
// Copyright 2015 The Authors. All rights reserved.
|
||
// Use of this source code is governed by a BSD-style
|
||
// license that can be found in the LICENSE file.
|
||
|
||
package html
|
||
|
||
import (
|
||
"bytes"
|
||
"fmt"
|
||
)
|
||
|
||
func ExampleEscapeString() {
|
||
fmt.Println(EscapeString(`<a href="https://www.google.com/search?q=something&ie=utf-8">Google Search</a>`))
|
||
|
||
// Output:
|
||
// <a href="https://www.google.com/search?q=something&ie=utf-8">Google Search</a>
|
||
}
|
||
|
||
func ExampleWriteEscapedString() {
|
||
var buf bytes.Buffer
|
||
WriteEscapedString(&buf, `<a href="https://www.google.com/search?q=something&ie=utf-8">Google Search</a>`)
|
||
fmt.Println(buf.String())
|
||
|
||
// Output:
|
||
// <a href="https://www.google.com/search?q=something&ie=utf-8">Google Search</a>
|
||
}
|
||
|
||
func ExampleParseEntity() {
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("""))
|
||
fmt.Println(ParseEntity("�"))
|
||
|
||
// Output:
|
||
// " 6
|
||
// " 6
|
||
// " 5
|
||
// " 12
|
||
// " 11
|
||
// 0
|
||
// 0
|
||
// <20> 11
|
||
}
|
||
|
||
func ExampleUnescapeString() {
|
||
fmt.Println(UnescapeString(" & © Æ Ď ¾ ℋ ⅆ ∲ # Ӓ Ϡ � " ആ ಫ   &x; &#; &#x; &ThisIsWayTooLongToBeAnEntityIsntIt; &hi?; © &MadeUpEntity;"))
|
||
|
||
// Output:
|
||
// & © Æ Ď ¾ ℋ ⅆ ∲ # Ӓ Ϡ <20> " ആ ಫ   &x; &#; &#x; &ThisIsWayTooLongToBeAnEntityIsntIt; &hi?; © &MadeUpEntity;
|
||
}
|