SetMode changes the output mode.
(newMode OutputMode)
| 257 | |
| 258 | // SetMode changes the output mode. |
| 259 | func (b *Buffer) SetMode(newMode OutputMode) { |
| 260 | if b.mode == newMode { |
| 261 | // noop |
| 262 | return |
| 263 | } |
| 264 | if b.mode == UnsafeEscaped || b.mode == SafeEscaped { |
| 265 | b.escapeToEnd(b.mode == UnsafeEscaped /* breakNewLines */) |
| 266 | } |
| 267 | if b.markerOpen { |
| 268 | b.endRedactable() |
| 269 | } |
| 270 | b.validUntil = len(b.buf) |
| 271 | b.mode = newMode |
| 272 | } |
| 273 | |
| 274 | // Reset resets the buffer to be empty, |
| 275 | // but it retains the underlying storage for use by future writes. |