Documentation
¶
Index ¶
Constants ¶
const KittyChunk = 4096
KittyChunk is the payload size per escape.
Kitty's protocol requires the base64 be split, and 4096 is the documented chunk size. Larger works on kitty itself and breaks through tmux, which has its own buffer limits.
Variables ¶
This section is empty.
Functions ¶
func ITermImage ¶
ITermImage encodes a PNG for iTerm2's protocol.
One sequence, no chunking. `inline=1` draws it rather than offering a download, and preserveAspectRatio keeps a tree diagram from being squashed into its box.
func KittyImage ¶
KittyImage encodes a PNG for kitty's graphics protocol.
cols and rows bound the drawing to a cell box, so a diagram cannot push the statement off the screen — the terminal scales to fit.
func Passthrough ¶
Passthrough wraps an escape so it survives tmux.
tmux eats sequences it does not recognise unless `allow-passthrough` is on, and even then the payload must be wrapped in its own DCS and every ESC inside it doubled — otherwise tmux terminates the wrapper at the first one and prints the rest as text.
`leetui doctor` reports when passthrough is off, because the failure is otherwise completely silent: no error anywhere, just a figure that never appears.
func ToPNG ¶
ToPNG re-encodes an image so kitty can draw it.
Kitty's f=100 means PNG. LeetCode serves plenty of JPEGs, and handing one over with f=100 produces no picture and no error — the terminal simply fails to decode and nothing appears, which is the silent failure this whole path is trying to avoid.
A PNG passes through untouched: re-encoding one would cost time and lose nothing.
Types ¶
type Document ¶
type Document struct {
// Markdown is ready for Glamour.
Markdown string
// Images are the URLs behind each bracket marker, in the order they appear.
// Marker "[▸ img 2 …]" is Images[1].
Images []Image
}
Document is converted content plus the assets referenced from it.
func EditorialToMarkdown ¶
EditorialToMarkdown reduces an editorial's embedded HTML to markers.
Split out from Editorial so it can be tested without a terminal renderer, and so a caller that wants the markdown (a future "save the editorial next to the solution") does not have to render it first.
func HTMLToMarkdown ¶
HTMLToMarkdown converts a LeetCode problem statement or editorial.