LiaScript / LiaScript-Exporter

Export LiaScript courses into SCORM1.2 & 2004, IMS, PDF or a standalone WEB project ...
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

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

Open foreveremain opened 1 year ago

foreveremain commented 1 year ago

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 ?

andre-dietrich commented 1 year ago

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 commented 1 year ago

@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
SebastianZug commented 1 year ago

@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 
foreveremain commented 1 year ago

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.

andre-dietrich commented 1 year ago

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

foreveremain commented 1 year ago

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