[latex] remove svg from latex priority#176
Conversation
|
@choldgraf I am not entirely sure how the solution I tried updating this from |
|
@chrisjsewell @choldgraf I don't see any docs on how to generate the https://myst-nb.readthedocs.io/en/latest/develop/contributing.html#how-to-write-tests I'll also submit a docs PR to document once I know. |
|
Ah - so in this case, If you want to regenerate the XML file on disk, just delete it, and re-run the tests. The test will fail the first time, saying the file doesn't exist, and it will create the file in the process. You should then inspect the file and make sure it looks correct. If so, re-run the test and it should pass. |
Easier than that, just run |
:-O |
> pytest --force-regen
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --force-regen
inifile: /Users/matthewmckay/repos-collab/ebp/MyST-NB/pytest.ini
rootdir: /Users/matthewmckay/repos-collab/ebp/MyST-NB |
|
@choldgraf it looks like the |
|
Is it an embedded file from markdown? Hmm weird. We could just point it to some other image file that's already in the repo |
Roger that. I'll just replace it -- seems only to be used in the one |
|
|
hmm - they look OK to me (though tests aren't passing). If the tests end up being brittle or platform dependent, then we can run the tests on a subset of the generated XML if need be |
|
Btw, should we be entirely removing SVG from the priority list or just moving it to the bottom? This would be useful when the only output is SVG, in conjunction with sphinx.ext.imgconverter or sphinxcontrib-svg2pdfconverter. |
@chrisjsewell I have removed it from |
Yes but that's the point; these extensions convert SVGs to PNG/PDF during the creation of latex outputs.
What would you be demoting it behind? SVG should most definitely be preferential to PNG/JPEG for HTML |
|
ah sorry @chrisjsewell I misunderstood your previous comment. I see what you're saying. Still learning how this |
Yep that's the idea; they generally call on an external program like imagemagik, libRSVG or inkscape to convert them (which you obviously also need to have installed). Whether they are currently compatible with myst-nb is something I think should definitely be tested at some point; in terms of the stage in the sphinx process at which both are called. I know that I certainly use packages that only output SVG (like graphviz), so it would be good to still have a way to use these output when creating PDFs, and we should document the preferential way to do this somewhere in the documentation and/or in jupyterbook. The main thing with graphics is that IMO, where possible, you should be looking to use vectorised (SVG/PDF) graphics, which have lossless quality with scaling, over rasterized (PNG/JPEG) ones. |
|
thanks @chrisjsewell -- that's helpful info. How do you trigger the conversion though. When |
For SVG in standard rST files the conversion is just triggered by adding the extension to The two sphinx extensions I mentioned do it on the sphinx end (prior to writing latex): this could be an issue, given that we inject the image into the doctree at quite a late stage (hence why I am not certain of compatibility). In the last few years there is now also a latex package which does similar on the latex end: https://ctan.org/pkg/svg?lang=en, which may be another option. This should be raised as an issue to look into as a long-term goal |
|
Looking over the code again; it looks like we "hard-code" in the priority lists: Line 18 in afba1fe As opposed to in jupyter-sphinx, where it is a configuration variable (albeit only allowing for a single list and not per builder): https://github.com/jupyter/jupyter-sphinx/blob/6a0df8575fd1fc76e1258aab300ec415eee92569/jupyter_sphinx/__init__.py#L155 I think the priority lists should be made configurable, to cope with use cases like this; whereby in general SVG should not be in the priority list for latex, since it will fail, but then you may want to add it in if you are also using an extension that makes it compatible. |
|
thanks @chrisjsewell I agree with configurability. Looking at one step ahead I see - thanks! |
|
Just opened an issue 👍 |
|
Regenerating the support > assert filenames == {
"complex_outputs_17_0.svg",
"complex_outputs.ipynb",
"complex_outputs_17_0.pdf",
"complex_outputs.py",
"complex_outputs_24_0.png",
"complex_outputs_13_0.jpg",
}
E AssertionError: assert {'complex_out...uts_24_0.png'} == {'complex_out...uts_24_0.png'}
E Extra items in the left set:
E 'complex_outputs_17_0.png'
E Extra items in the right set:
E 'complex_outputs_17_0.pdf'
E 'complex_outputs_17_0.svg'
E Use -v to get the full diff
/repos-collab/ebp/MyST-NB/tests/test_parser.py:61: AssertionError
---------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------
{'complex_outputs.ipynb', 'complex_outputs_24_0.png', 'complex_outputs_17_0.png', 'complex_outputs.py', 'complex_outputs_13_0.jpg'}
=============================================================== short test summary info ===============================================================
FAILED tests/test_parser.py::test_complex_outputs - AssertionError: assert {'complex_out...uts_24_0.png'} == {'complex_out...uts_24_0.png'}
============================================================ 1 failed, 34 passed in 21.13s ============================================================ |
Before we were getting pdf and svg outputs from cell 17, now we are only getting png. They're actually very useful functions for getting these packages to create optimal outputs for sphinx, and would be good if we could incorporate them somewhere in the executablebook stack |
Agreed. Don't understand why the change is in this PR from looking at what has changed. |
|
@choldgraf @chrisjsewell I made this change to the For some reason we are generating the Tests should pass now. |
Codecov Report
@@ Coverage Diff @@
## master #176 +/- ##
=======================================
Coverage 84.26% 84.26%
=======================================
Files 9 9
Lines 820 820
=======================================
Hits 691 691
Misses 129 129
Continue to review full report at Codecov.
|
|
choldgraf
left a comment
There was a problem hiding this comment.
LGTM - and you all are the latex experts so I will defer to your thinking on the best way to get it working. Are we ready to merge?
|
ping for @mmcky - it this is all ready to go then let's get it in, just need to hear from y'all if that's the case! |
|
sorry @choldgraf -- didn't see first message -- good to go. |
|
once this is merged I will test more widely |
|
ok let's do it! :-D |
This PR:
image/svg+xmlas a latex image option.