(in *Value, param *Value)
| 221 | } |
| 222 | |
| 223 | func filterTruncatecharsHTML(in *Value, param *Value) (*Value, *Error) { |
| 224 | value := in.String() |
| 225 | newLen := max(param.Integer()-3, 0) |
| 226 | |
| 227 | newOutput := bytes.NewBuffer(nil) |
| 228 | |
| 229 | textcounter := 0 |
| 230 | |
| 231 | filterTruncateHTMLHelper(value, newOutput, func() bool { |
| 232 | return textcounter >= newLen |
| 233 | }, func(c rune, s int, idx int) int { |
| 234 | textcounter++ |
| 235 | newOutput.WriteRune(c) |
| 236 | |
| 237 | return idx + s |
| 238 | }, func() { |
| 239 | if textcounter >= newLen && textcounter < len(value) { |
| 240 | newOutput.WriteString("...") |
| 241 | } |
| 242 | }) |
| 243 | |
| 244 | return AsSafeValue(newOutput.String()), nil |
| 245 | } |
| 246 | |
| 247 | func filterTruncatewords(in *Value, param *Value) (*Value, *Error) { |
| 248 | words := strings.Fields(in.String()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…