forked from candid82/joker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a_html.go
57 lines (42 loc) · 1.19 KB
/
a_html.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// This file is generated by generate-std.joke script. Do not edit manually!
package html
import (
"html"
. "github.com/candid82/joker/core"
)
var htmlNamespace = GLOBAL_ENV.EnsureNamespace(MakeSymbol("joker.html"))
var escape_ Proc = func(args []Object) Object {
c := len(args)
switch {
case c == 1:
s := ExtractString(args, 0)
res := html.EscapeString(s)
return MakeString(res)
default:
PanicArity(c)
}
return NIL
}
var unescape_ Proc = func(args []Object) Object {
c := len(args)
switch {
case c == 1:
s := ExtractString(args, 0)
res := html.UnescapeString(s)
return MakeString(res)
default:
PanicArity(c)
}
return NIL
}
func init() {
htmlNamespace.ResetMeta(MakeMeta(nil, "Provides functions for escaping and unescaping HTML text.", "1.0"))
htmlNamespace.InternVar("escape", escape_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("s"))),
`Escapes special characters like < to become <. It escapes only five such characters: <, >, &, ' and ".`, "1.0"))
htmlNamespace.InternVar("unescape", unescape_,
MakeMeta(
NewListFrom(NewVectorFrom(MakeSymbol("s"))),
`Unescapes entities like < to become <.`, "1.0"))
}