Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
67 lines (60 loc) · 1.61 KB

File metadata and controls

67 lines (60 loc) · 1.61 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
package fmt
// EscapeAttr returns a string safe to place inside an HTML attribute value.
func (c *Conv) EscapeAttr() string {
return c.Replace("&", "&").
Replace("\"", """).
Replace("'", "'").
Replace("<", "&lt;").
Replace(">", "&gt;").
String()
}
// EscapeHTML returns a string safe for inclusion into HTML content.
func (c *Conv) EscapeHTML() string {
return c.Replace("&", "&amp;").
Replace("<", "&lt;").
Replace(">", "&gt;").
Replace("\"", "&quot;").
Replace("'", "&#39;").
String()
}
// Html creates a string for HTML content, similar to Translate but without automatic spacing.
// It supports two modes:
// 1. Format mode: If the first argument is a string containing '%', it behaves like Fmt.
// 2. Concatenation mode: Otherwise, it concatenates arguments (translating with hook) without spaces.
func Html(values ...any) *Conv {
c := GetConv()
if len(values) == 0 {
return c
}
// PASO 1: Detección de formato
if format, ok := values[0].(string); ok {
// Simple check for % to detect format string
hasFormat := false
for i := 0; i < len(format)-1; i++ {
if format[i] == '%' {
if c.isValidWriteFormatChar(rune(format[i+1])) {
hasFormat = true
break
}
}
}
if hasFormat {
// Use Fmt logic
return c.wrFormat(BuffOut, format, values[1:]...)
}
}
// PASO 2: Concatenación sin espacios
for _, val := range values {
switch v := val.(type) {
case string:
c.WrString(BuffOut, tr(v))
default:
c.AnyToBuff(BuffWork, v)
if c.hasContent(BuffWork) {
c.WrString(BuffOut, c.GetString(BuffWork))
c.ResetBuffer(BuffWork)
}
}
}
return c
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.