useblocks / sphinx-simplepdf

A simple PDF builder for Sphinx documentations
https://sphinx-simplepdf.readthedocs.io
MIT License
36 stars 15 forks source link

Code that has been highlighted is not displayed #10

Closed 1kastner closed 1 year ago

1kastner commented 2 years ago

I used nbsphinx to create some highlighted code. The first block with the import statements looks fine, afterwards the code is not visible anymore, see here:

grafik

By the way, I am using Adobe to read the PDF.

1kastner commented 2 years ago

Maybe some of the warnings are a reason for that?

WARNING: Font-face 'D3 Euronism' cannot be loaded
WARNING: Font-face 'D3 Euronism Bold italic' cannot be loaded
WARNING: Font-face 'D3 Euronism Bold' cannot be loaded       
WARNING: Font-face 'D3 Euronism italic' cannot be loaded     
WARNING: Font-face 'Helvetica Neue Bold' cannot be loaded    
WARNING: Font-face 'Helvetica Neue Light' cannot be loaded   
WARNING: Font-face 'Helvetica Neue Medium' cannot be loaded  
WARNING: Font-face 'Helvetica Neue Regular' cannot be loaded 
WARNING: Font-face 'Fira Sans' cannot be loaded
WARNING: Font-face 'Fira Sans' cannot be loaded
WARNING: Font-face 'Fira Sans' cannot be loaded
WARNING: Font-face 'Fira Sans' cannot be loaded
WARNING: Font-face 'Fira Sans' cannot be loaded
WARNING: Font-face 'fontawesome-webfont' cannot be loaded
WARNING: Ignored `text-shadow: none` at 635:3, unknown property.
WARNING: Ignored `flex-basis: unset` at 734:7, invalid value.
WARNING: Ignored `min-width: unset` at 767:3, invalid value.
WARNING: Ignored `max-width: unset` at 768:3, invalid value.
WARNING: Ignored `white-space: -o-pre-wrap` at 791:3, invalid value.
ERROR: Failed to load stylesheet at file:///C:/.../docs/_build/simplepdf/_static/styles/main.css: URLError: <urlopen error [WinError 2] Das System kann die angegebene Datei nicht finden: 'C:\\...\\docs\\_build\\simplepdf\\_static\\styles\\main.css'>
WARNING: Anchor defined twice: 'id1'
WARNING: Anchor defined twice: 'id2'
WARNING: Anchor defined twice: 'id3'
WARNING: Anchor defined twice: 'id4'
WARNING: Anchor defined twice: 'id5'
WARNING: Anchor defined twice: 'id6'
WARNING: Anchor defined twice: 'id1'
WARNING: Anchor defined twice: 'id10'
WARNING: Anchor defined twice: 'id7'
WARNING: Anchor defined twice: 'id3'
WARNING: Anchor defined twice: 'id9'
WARNING: Anchor defined twice: 'id8'
WARNING: Anchor defined twice: 'id6'
WARNING: Anchor defined twice: 'id5'
WARNING: Anchor defined twice: 'id4'
WARNING: Anchor defined twice: 'id2'
ERROR: No anchor # for internal URI reference
ERROR: No anchor #id11 for internal URI reference
ERROR: No anchor #id11 for internal URI reference
ERROR: No anchor #id12 for internal URI reference
ERROR: No anchor #id13 for internal URI reference
ERROR: No anchor #id13 for internal URI reference
ERROR: No anchor #id14 for internal URI reference
ERROR: No anchor #id15 for internal URI reference
ERROR: No anchor # for internal URI reference
ERROR: No anchor # for internal URI reference
ERROR: No anchor # for internal URI reference
ERROR: No anchor # for internal URI reference
build succeeded.

The HTML page is in _build\simplepdf.

Do I need to manually install those fonts? And why does it try to open C:\\...\\docs\\_build\\simplepdf\\_static\\styles\\main.css? No such file exists. Mine is called custom.css as indicated in my conf.py. Is that bad in your case? And I have no idea where all these anchors come from. That is nothing I have created manually. However, I use some extensions that might have caused that.

Sachin-Suresh commented 1 year ago

I don't use any extensions. I tried with the new Sphinx installation and I still get these font warnings. Let me know if you find a workaround @1kastner

1kastner commented 1 year ago

@Sachin-Suresh I have not found any workaround.

danwos commented 1 year ago

The fonts warnings are just warnings, and I'm not sure if we can fix them easily, as you normally set multiple fonts in CSS, in the case some of them are not installed or available on the used operating system. This would also be more the problem of the used weasyprint lib. (Or we can configure it to suppress such messages).

For the nbsphinx-problem, do you have some example code for me? Would help me to reproduce the problem the right way. I would also add it to our DEMO-PDF, so that we can have an eye on it for future releases.

1kastner commented 1 year ago

Thanks for the explanation. Well, a small show-off of nbsphinx you can find at https://github.com/spatialaudio/nbsphinx/blob/master/doc/code-cells.ipynb. If that whole notebook takes too much space, the Jupyter Notebook could also be reduced to the following cells:

grafik

The short explanation of how to set it up can be found at https://nbsphinx.readthedocs.io/en/0.8.9/ and the prerequisites at https://nbsphinx.readthedocs.io/en/0.8.9/installation.html#nbsphinx-Prerequisites.

1kastner commented 1 year ago

See #25