The ImageFormatter
always creates a PNG output which width depends on the line length.
For example, this PNG is 192 pixels wide:
and this is 384:
Is there a setting in Pygments
to emulate a 80 column output, so all images will have the same width?
This is the code I used to produce the examples:
#!/usr/bin/python3from pygments import highlightfrom pygments import lexersfrom pygments.formatters.img import ImageFormatterfrom pygments.styles import get_style_by_name, get_all_styleslexer = lexers.get_lexer_by_name('C')source_short = 'printf("%d\\n", i);'source_long = 'printf("variable i is equal to %d.\\n", i);'formatter = ImageFormatter(full = True, style = get_style_by_name('vim'))open('short.png', 'wb').write(highlight(source_short, lexer, formatter))formatter = ImageFormatter(full = True, style = get_style_by_name('vim'))open('long.png', 'wb').write(highlight(source_long, lexer, formatter))