htab = []byte{'\t'};
htabs = [...]byte{'\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t'};
newlines = [...]byte{'\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n'}; // more than maxNewlines
- ampersand = strings.Bytes("&");
- lessthan = strings.Bytes("<");
- greaterthan = strings.Bytes(">");
+
+ esc_quot = strings.Bytes("""); // shorter than """
+ esc_apos = strings.Bytes("'"); // shorter than "'"
+ esc_amp = strings.Bytes("&");
+ esc_lt = strings.Bytes("<");
+ esc_gt = strings.Bytes(">");
)
// next segment start
i0 = i+1;
- case '&', '<', '>':
+ case '"', '\'', '&', '<', '>':
if p.Mode & GenHTML != 0 {
// write segment ending in b
p.write0(data[i0 : i]);
// write HTML-escaped b
var esc []byte;
switch b {
- case '&': esc = ampersand;
- case '<': esc = lessthan;
- case '>': esc = greaterthan;
+ case '"': esc = esc_quot;
+ case '\'': esc = esc_apos;
+ case '&': esc = esc_amp;
+ case '<': esc = esc_lt;
+ case '>': esc = esc_gt;
}
p.write0(esc);