aboutsummaryrefslogtreecommitdiff
path: root/lib/html/example_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-03-06 03:42:00 +0700
committerShulhan <ms@kilabit.info>2024-03-09 01:10:17 +0700
commite730418289d80985c5d48946353961a357a4b532 (patch)
tree9e573bf4fca975775eb25f32448f755a325880a8 /lib/html/example_test.go
parent1e7cb99f42bcd41e98326bd9406d3cecfb2a4542 (diff)
downloadpakakeh.go-e730418289d80985c5d48946353961a357a4b532.tar.xz
lib: move package "net/html" to "lib/html"
Putting "html" under "net" package make no sense. Another reason is to make the package flat under "lib/" directory.
Diffstat (limited to 'lib/html/example_test.go')
-rw-r--r--lib/html/example_test.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/html/example_test.go b/lib/html/example_test.go
new file mode 100644
index 00000000..d0582555
--- /dev/null
+++ b/lib/html/example_test.go
@@ -0,0 +1,51 @@
+// Copyright 2022, Shulhan <ms@kilabit.info>. 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 "fmt"
+
+func ExampleNormalizeForID() {
+ fmt.Println(NormalizeForID(""))
+ fmt.Println(NormalizeForID(" id "))
+ fmt.Println(NormalizeForID(" ID "))
+ fmt.Println(NormalizeForID("_id.1"))
+ fmt.Println(NormalizeForID("1-d"))
+ fmt.Println(NormalizeForID(".123 ABC def"))
+ fmt.Println(NormalizeForID("test 123"))
+ fmt.Println(NormalizeForID("⌘"))
+ // Output:
+ // _
+ // _id_
+ // _id_
+ // _id_1
+ // _1-d
+ // _123_abc_def
+ // test_123
+ // ___
+}
+
+func ExampleSanitize() {
+ input := `
+<html>
+ <title>Test</title>
+ <head>
+ </head>
+ <body>
+ This
+ <p> is </p>
+ a
+ <a href="/">link</a>.
+ An another
+ <a href="/">link</a>.
+ </body>
+</html>
+`
+
+ out := Sanitize([]byte(input))
+ fmt.Printf("%s", out)
+
+ // Output:
+ // This is a link. An another link.
+}