mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
lazy initialize html5entities
This commit is contained in:
parent
697e44ce88
commit
3847ca20c6
2 changed files with 2140 additions and 2127 deletions
|
|
@ -6,7 +6,7 @@ require (
|
|||
github.com/88250/lute v1.7.5
|
||||
github.com/gomarkdown/markdown v0.0.0-20230322041520-c84983bdbf2a
|
||||
github.com/russross/blackfriday/v2 v2.1.0
|
||||
github.com/yuin/goldmark v1.2.1
|
||||
github.com/yuin/goldmark v0.0.0
|
||||
gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a
|
||||
)
|
||||
|
||||
|
|
@ -22,3 +22,4 @@ require (
|
|||
)
|
||||
|
||||
replace gopkg.in/russross/blackfriday.v2 v2.0.1 => github.com/russross/blackfriday/v2 v2.0.1
|
||||
replace github.com/yuin/goldmark v0.0.0 => ../../
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//nolint:golint,lll,misspell
|
||||
package util
|
||||
|
||||
import "sync"
|
||||
|
||||
// An HTML5Entity struct represents HTML5 entitites.
|
||||
type HTML5Entity struct {
|
||||
Name string
|
||||
|
|
@ -11,11 +13,18 @@ type HTML5Entity struct {
|
|||
// LookUpHTML5EntityByName returns (an HTML5Entity, true) if an entity named
|
||||
// given name is found, otherwise (nil, false).
|
||||
func LookUpHTML5EntityByName(name string) (*HTML5Entity, bool) {
|
||||
v, ok := html5entities[name]
|
||||
v, ok := html5entities()[name]
|
||||
return v, ok
|
||||
}
|
||||
|
||||
var html5entities = map[string]*HTML5Entity{
|
||||
var html5entitiesOnce sync.Once // TODO: uses sync.OnceValue for future
|
||||
|
||||
var _html5entities map[string]*HTML5Entity
|
||||
|
||||
func html5entities() map[string]*HTML5Entity {
|
||||
html5entitiesOnce.Do(func() {
|
||||
_html5entities =
|
||||
map[string]*HTML5Entity{
|
||||
"AElig": {Name: "AElig", CodePoints: []int{198}, Characters: []byte{0xc3, 0x86}},
|
||||
"AMP": {Name: "AMP", CodePoints: []int{38}, Characters: []byte{0x26}},
|
||||
"Aacute": {Name: "Aacute", CodePoints: []int{193}, Characters: []byte{0xc3, 0x81}},
|
||||
|
|
@ -2140,4 +2149,7 @@ var html5entities = map[string]*HTML5Entity{
|
|||
"zscr": {Name: "zscr", CodePoints: []int{120015}, Characters: []byte{0xf0, 0x9d, 0x93, 0x8f}},
|
||||
"zwj": {Name: "zwj", CodePoints: []int{8205}, Characters: []byte{0xe2, 0x80, 0x8d}},
|
||||
"zwnj": {Name: "zwnj", CodePoints: []int{8204}, Characters: []byte{0xe2, 0x80, 0x8c}},
|
||||
}
|
||||
})
|
||||
return _html5entities
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue