commit be287bea29d2b7f0494bc0cfb1b2bb2713a31b98 from: ale date: Sat Aug 1 05:45:47 2026 UTC Center code-execution text output, demo a GIF saved from code UnicodePlots (and any other code block's plain stdout) now centers the same way image-based plots already do via their own PadLeft, instead of hugging the left edge while GR/CairoMakie output sits in the middle. Also adds a Julia example that saves an animated GIF from a ctrl+e block -- confirms the existing GIF cache path (Fase 7) already applies to execution-produced images too, no code change needed there. commit - bcb2ab71430e9ef8b8c9e37376d41437b962d075 commit + be287bea29d2b7f0494bc0cfb1b2bb2713a31b98 blob - a5aeff82ee80eb01d2b52f5fa9d8eb2728087122 blob + 741f9b276a37a7b8fb18170ef6e3084d97843096 --- examples/julia.md +++ examples/julia.md @@ -47,3 +47,20 @@ ax = Axis(fig[1, 1], title = "x²") lines!(ax, 1:100, x -> x^2) save("fig.png", fig) ``` + +--- + +### An animated GIF from code + +A saved `.gif` is displayed the same way any other executed-code image +is -- and if it has more than one frame, it plays back in a loop just +like a `.gif` referenced directly in markdown. + +```julia +using Plots +gr() +anim = @animate for i in 1:40 + plot(1:100, x -> sin(x / 10 + i / 4), ylim=(-1.2, 1.2), legend=false) +end +gif(anim, "wave.gif", fps=20) +``` blob - 06971dd83e430fd638a39992dd0d7f24c60c8c31 blob + 2e01e0a3fa3793d83c1b18981913c91b5f1248aa --- internal/model/model.go +++ internal/model/model.go @@ -553,7 +553,13 @@ func (m Model) renderSlide(md string, includeVirtualTe slide, err := r.Render(slide) slide = strings.ReplaceAll(slide, "\t", tabSpaces) if includeVirtualText { - slide += m.VirtualText + if m.VirtualText != "" { + // Centered the same way images are (via their own PadLeft), + // so text-only output -- UnicodePlots' terminal-drawn charts, + // in particular -- lines up with the image-based plots + // instead of hugging the left edge. + slide += lipgloss.PlaceHorizontal(contentWidth, lipgloss.Center, m.VirtualText) + } if m.executing { slide += "\n" + spin + " ejecutando…" }