C2DH / journal-of-digital-history

frontend app for our Digital Journal
GNU General Public License v3.0
19 stars 4 forks source link

Images not displayed - output data image/png - R notebook #511

Closed eliselavy closed 1 year ago

eliselavy commented 1 year ago

Problem of images displayed related to R's notebook :

https://github.com/jdh-observer/jdh001-9HcfToh7EYm8/blob/main/skim-article.ipynb https://journalofdigitalhistory.org/en/notebook-viewer/JTJGcHJveHktZ2l0aHVidXNlcmNvbnRlbnQlMkZqZGgtb2JzZXJ2ZXIlMkZqZGgwMDEtOUhjZlRvaDdFWW04JTJGbWFpbiUyRnNraW0tYXJ0aWNsZS5pcHluYg==

=> the table of content is ok - but no figures displayed

Other example here:

https://github.com/jdh-observer/jdh001-MyifnvNPDgUx/blob/main/taking-the-measure-of-social-democracy.ipynb

https://journalofdigitalhistory.org/en/notebook-viewer/JTJGcHJveHktZ2l0aHVidXNlcmNvbnRlbnQlMkZqZGgtb2JzZXJ2ZXIlMkZqZGgwMDEtTXlpZm52TlBEZ1V4JTJGbWFpbiUyRnRha2luZy10aGUtbWVhc3VyZS1vZi1zb2NpYWwtZGVtb2NyYWN5LmlweW5i?idx=75

eliselavy commented 1 year ago

R 's notebook - output data image/png and not data/image/jpeg

Screenshot 2023-01-25 at 14 06 07

but doesn't seem related as in some article output data image/png are displayed:

Screenshot 2023-01-25 at 14 13 19 https://journalofdigitalhistory.org/en/article/JJszM3GwAYDs?idx=137

danieleguido commented 1 year ago

The encoding was not right for the background-image css property, I've removed newlines in base64 encoding and it works. in principle this could be set from python code itself it seems, see https://stackoverflow.com/questions/30647219/remove-the-new-line-n-from-base64-encoded-strings-in-python3, they add newline=false No idea why R outputs newlines, but it will be fixed as soon as PR https://github.com/C2DH/journal-of-digital-history/pull/510 is merged.

Screenshot 2023-01-25 at 16 56 46