mgieseki / dvisvgm

A fast DVI, EPS, and PDF to SVG converter
https://dvisvgm.de
GNU General Public License v3.0
295 stars 28 forks source link

Request for reduced information verbosity level/flag #258

Closed tecosaur closed 6 months ago

tecosaur commented 6 months ago

Hello again!

In the continuing optimisation efforts around org-mode's incoming new preview system, we've identified that reducing the amount of output (and thus text processing required) from dvisvgm can make an appreciable difference when producing 100+ previews.

Currently, we scan the stdout to see use the generated SVGs as they are produced, which seems to be information in the "info" (4) verbosity category.

~$ dvisvgm --page=1- --optimize --clipjoin --relative --no-fonts --bbox=preview -o /tmp/org-tex-%9p.svg /tmp/org-tex-V1WgWm.dvi
pre-processing DVI file (format version 2)
processing page 1
  applying bounding box set by preview package (version 13.1)
  width=25.797028pt, height=6.811859pt, depth=2.581879pt
  graphic size: 25.797028pt x 9.393738pt (9.066618mm x 3.301521mm)
  output written to org-tex-000000001.svg
1 of 1 page converted in 0.0549378 seconds

The only bit of information needed here is the file name written to, however, with the available verbosity flags we can't see a way to get rid of the extraneous output without also losing the crucial line containing output written to org-tex-000000001.svg.

It would be great if we could get just the filename line + error/warning messages somehow.

mgieseki commented 6 months ago

With the current options it's not possible to only print the filename, unfortunately, but it shouldn't be too complicated to add this functionality. To keep compatibility with previous versions, it's probably not a good idea to introduce a separate verbosity flag for the filename. Maybe I could add a new option --message to print arbitrary user messages that may contain the macros already evaluated by special dvisvgm:message. I just have to add macro svgfile. Then you could call dvisvgm with -v3 --message "Output file: {?svgfile}" or something like that.

mgieseki commented 6 months ago

As proposed above, I've added option --message that allows you to output your own message text after creating an SVG file. It will be available as of the next version 3.2. If you want to use it in your scripts, you probably need to check the available dvisvgm version to prevent errors.

tecosaur commented 6 months ago

Thanks Martin!

I've been wondering if this could be done in a backwards-compatible way, but that does seem like a bit of a stretch (I guess depending on the implementation a new verbosity number could maybe work).

mgieseki commented 6 months ago

I thought about assigning the filename output to its own verbosity flag, but decided against it because you also needed to adapt the verbosity levels depending on the dvisvgm version, e.g. 7 for versions < 3.2. and 11 for the newer ones. To me, the current, more generic way is more flexible and might support further needs of other users without having to introduce many special verbosity flags.

tecosaur commented 5 months ago

Makes sense, thanks again!

mgieseki commented 5 months ago

You're welcome.