mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 10:48:53 +01:00
doc: Escape HTML comments properly
This commit is contained in:
parent
5f9eea5e6c
commit
2132925b88
18
_docs/gen.go
18
_docs/gen.go
@ -83,7 +83,23 @@ func init() {
|
||||
}
|
||||
|
||||
func comment(text string) template.HTML {
|
||||
// TODO: text should be escaped
|
||||
// http://www.w3.org/TR/html-markup/syntax.html#comments
|
||||
// The text part of comments has the following restrictions:
|
||||
// * must not start with a ">" character
|
||||
// * must not start with the string "->"
|
||||
// * must not contain the string "--"
|
||||
// * must not end with a "-" character
|
||||
|
||||
for strings.HasPrefix(text, ">") {
|
||||
text = text[1:]
|
||||
}
|
||||
for strings.HasPrefix(text, "->") {
|
||||
text = text[2:]
|
||||
}
|
||||
text = strings.Replace(text, "--", "", -1)
|
||||
for strings.HasSuffix(text, "-") {
|
||||
text = text[:len(text)-1]
|
||||
}
|
||||
return template.HTML("<!--\n" + text + "\n-->")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user