LiaScript-Exporter icon indicating copy to clipboard operation
LiaScript-Exporter copied to clipboard

--pdf-stylesheet not working with example custom.css

Open foreveremain opened this issue 2 years ago • 6 comments

Firstly, thanks for LiaScript .. ! It's a fantasticly capable way of disseminating materials :)

I was wanting to customise PDF export so tried out the following, based on the README. However, I've been getting pupeteer errors:

cat pdf-export.css.example 
:root {
    --color-highlight: 2, 255, 0;
    --color-background: 122, 122, 122;
    --color-border: 0, 0, 0;
    --color-highlight-dark: 0, 0, 0;
    --color-highlight-menu: 0, 0, 0;
    --color-text: 0, 0, 255;
    --global-font-size: 1rem;
    --font-size-multiplier: 2;
}
(base) M-000981:jalview-3dbeacons jprocter$ liaex --format pdf   -o example   --pdf-stylesheet pdf-export.css.example   -i https://github.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/blob/master/08_Objekte.md
Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.
depending on the size of the course, this can take a while, please be patient...
/usr/local/lib/node_modules/@liascript/exporter/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221
            throw new Error('Evaluation failed: ' + helper_js_1.helper.getExceptionMessage(exceptionDetails));
                  ^

Error: Evaluation failed: Event
    at ExecutionContext._evaluateInternal (/usr/local/lib/node_modules/@liascript/exporter/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/usr/local/lib/node_modules/@liascript/exporter/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
    at async $fe4c9e5866fc6c52$export$372e2d09604f52f0 (/usr/local/lib/node_modules/@liascript/exporter/dist/index.js:12583:9)

Node.js v18.10.0

I realise this might be an incompatibility issue - I upgraded to node 20.3 to check - still no dice (but I do also get warnings suggesting I should downgrade to 14).

Any suggestions ?

foreveremain avatar Jun 12 '23 21:06 foreveremain

Hi and thanks for trying out ;-)

puppeteer might have done some changes, which now require an additional install step. I don't now, if the --pdf-preview option is working for you, or the general PDF export? However, if this is not the case, you have to perform the following installation step manually:

cd /usr/local/lib/node_modules/@liascript/exporter/node_modules/puppeteer
node install.js

I am currently using node v16.19.0, you could try to downgrade... It would be interesting if this solves the issue. But, you can always manually add the style to your document. This injection is only a shortcut. To do so, simply add the path of your style to the main comment:

<!--
...
link: custom.css
-->

# Main Title

...

This should do the same job. There you can also change the style of the liascript-classes, the root variables are only the basis. And if want to change the icon, you can do this with:

<!--
...
icon: https://image-url.png
-->

# Main Title

...

andre-dietrich avatar Jun 13 '23 08:06 andre-dietrich

@foreveremain ... I just saw, that you send an example command, I tried it and it did not work, but there was the URL not working anymore. I guess @SebastianZug changed the names of the files :see_no_evil: ... so I have to update the URLs in the READMEs ... sorry for that, you could try:

liaex --format pdf --pdf-preview --pdf-stylesheet YOUR.css -i https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/08_PythonGrundlagen.md

andre-dietrich avatar Jun 13 '23 08:06 andre-dietrich

@foreveremain, @andre-dietrich ... That's correct. Due to an adapted focus of this lecture, we renamed the individual files. The current version addresses data aggregation with microcontrollers (C++) and data analysis based on Python. The urls of the corresponding files are:

https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/README.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/00_Einfuehrung.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/01_EingabeAusgabeDatentypen.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/02_OperatorenKontrollstrukturen.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/03_ArrayZeigerReferenzen.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/04_Funktionen.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/05_OOPI.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/06_OOPII.md
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/07_Microcontroller.md 
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/08_PythonGrundlagen.md 
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/09_PythonVertiefung.md 
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/10_Datenvisualisierung.md 
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/11_DatenAnalyse.md 
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_ProzeduraleProgrammierung/master/12_Anwendungen.md 

SebastianZug avatar Jun 13 '23 08:06 SebastianZug

thanks @andre-dietrich for the reminder of using link: to load my own css. That works.

As for the original issue: - adding --pdf-stylesheet to any invocation of liaex that otherwise works (ie a pdf is generated if requested) causes it to error out.

Adding --pdf-preview makes no difference to the error, except I see Chromium start up and then close.

I'll explore on another environment to check and post results here.

foreveremain avatar Jun 14 '23 11:06 foreveremain

@foreveremain ... but it is possible to generate pdfs, such that the inject-css causes the error only?

andre-dietrich avatar Jun 14 '23 11:06 andre-dietrich

no. there is no output file written at all. Chromium is crashing out after intial page load when css is passed via the argument.

foreveremain avatar Jun 15 '23 08:06 foreveremain