Closed pawamoy closed 2 years ago
There is a bit of weirdness with how Terminal
s are handled in the library, and it will be focused on in the new documentations. Basically, there exists a global terminal that basically everything uses to write/read information to, and it can be set using the ptg.set_global_terminal
function.
This shouldn't affect your use case, but it seems it does, since changing it to this:
terminal = ptg.Terminal(stream=StringIO(), size=(20, 20))
ptg.set_global_terminal(terminal)
with terminal.record() as recorder:
recorder.write(ptg.tim.parse(ptg.highlight_python(code)))
print(recorder.export_svg(inline_styles=True))
Seems to work perfectly well. Will look into it further, but using it this way should help for now.
Sidenote: Dimensions of 20x20 are very odd looking, so you probably wanna adjust them. I haven't been able to figure out a way to clip overflow in SVGs yet, so it might look a bit broken :(
Describe the bug See #67 (same code):
I can't seem to get the desired size for the generated SVG. It seems it uses my actual terminal size (vertical screen) rather than what I'm providing using the
size
parameter (zoomed out to see the full size):Expected behavior Respect the
size
value of the terminal when exporting a record to SVG.System information