IncrementalRenderer is a markdown renderer specialized for streaming use: it remembers the most recently rendered "stable prefix" of the input and, when the next call extends that prefix, re-renders only the new trailing region instead of the whole document. A "stable prefix" here is the portion of
| 22 | // |
| 23 | // IncrementalRenderer is not safe for concurrent use. |
| 24 | type IncrementalRenderer struct { |
| 25 | width int |
| 26 | |
| 27 | // inputPrefix is the longest stable prefix of the most recent input that |
| 28 | // ends at a block boundary. outputPrefix is its rendered counterpart. |
| 29 | // Both are empty until the first successful incremental render. |
| 30 | inputPrefix string |
| 31 | outputPrefix string |
| 32 | |
| 33 | // codeBlocksPrefix is the list of code blocks emitted while rendering the |
| 34 | // cached prefix, with Line indices relative to outputPrefix. |
| 35 | codeBlocksPrefix []CodeBlock |
| 36 | |
| 37 | // fallback is used for the actual rendering work; it is reused across calls |
| 38 | // so its parser pool (and chroma caches) stay warm. |
| 39 | fallback *FastRenderer |
| 40 | } |
| 41 | |
| 42 | // NewIncrementalRenderer creates a new incremental renderer with the given |
| 43 | // terminal width. |
nothing calls this directly
no outgoing calls
no test coverage detected