PreTeXtBook / pretext-cli

Command line interface for quickly creating, authoring, and building PreTeXt documents.
https://pretextbook.org
GNU General Public License v3.0
17 stars 17 forks source link

Add CLI support for slides #779

Open oscarlevin opened 2 months ago

oscarlevin commented 2 months ago

Currently this is done using a "custom" format, but we should be able to handle it directly.

sean-fitzpatrick commented 1 month ago

From a user POV, this is an "under the hood" distinction we might not even notice, since the custom format is set up for us when we use pretext new slideshow.

So it is fine to make the change, but also not a show-stopper with the status quo.

The one CLI change I would want is the behaviour of pretext view for a slideshow: currently it opens a directory page containing external/, generated/, and index.html. It would be better if the view command opened index.html directly.

sean-fitzpatrick commented 1 month ago

OK, there is one problem with using custom: the CLI doesn't know what outformat to use when building generated assets.

For a TikZ image there's an error I don't understand about not being able to determine the table of contents level. For Asymptote, since it doesn't know the outformat, it tries to build all of them.

sean-fitzpatrick commented 1 month ago

Since reveal.js is an HTML format, I would recomment using -f html for Asymptote generation: this will default to SVG for 2D images, and will produce WebGL for 3D images. Some outformats are not supported for 3D images.

Here is my CLI log output:

INFO    : PreTeXt-CLI version: 2.5.2

INFO    : PreTeXt project found in `/home/sean/slidemo/new-pretext-project`.
INFO    : Since no target was supplied, we will use "web".

INFO    : Generating assets for web
INFO    : converting latex-image pictures from /home/sean/slidemo/new-pretext-project/source/main.ptx to all graphics for placement in /home/sean/slidemo/new-pretext-project/generated-assets/latex-image
INFO    : extracting latex-image pictures from /home/sean/slidemo/new-pretext-project/source/main.ptx
INFO    : string parameters passed to extraction stylesheet: {'publisher': '/home/sean/slidemo/new-pretext-project/publication/publication.ptx'}
INFO    : discovering source file's directory name: /home/sean/slidemo/new-pretext-project/source
INFO    : verifying and expanding input directory: /home/sean/slidemo/new-pretext-project/source/../generated-assets
INFO    : input directory expanded to absolute path: /home/sean/slidemo/new-pretext-project/generated-assets
INFO    : verifying and expanding input directory: /home/sean/slidemo/new-pretext-project/source/../assets
INFO    : input directory expanded to absolute path: /home/sean/slidemo/new-pretext-project/assets
INFO    : XSL conversion of /home/sean/slidemo/new-pretext-project/source/main.ptx by /home/sean/.ptx/2.5.2/core/xsl/extract-latex-image.xsl
INFO    : messages from the log for XSL processing:
ERROR   : * PTX:ERROR: Table of Contents level (for LateX conversion) not determined
INFO    : successful application of /home/sean/.ptx/2.5.2/core/xsl/extract-latex-image.xsl
INFO    : converting img-tikz.tex to img-tikz.pdf
INFO    : cropping img-tikz.pdf to cropped-img-tikz.pdf
INFO    : renaming cropped-img-tikz.pdf to img-tikz.pdf
INFO    : converting img-tikz.pdf to img-tikz.svg
INFO    : converting img-tikz.pdf to img-tikz.png
INFO    : converting img-tikz.pdf to img-tikz.eps
INFO    : converting Asymptote diagrams from /home/sean/slidemo/new-pretext-project/source/main.ptx to ALL graphics for placement in /home/sean/slidemo/new-pretext-project/generated-assets/asymptote with method "AsyMethod.LOCAL"
INFO    : extracting Asymptote diagrams from /home/sean/slidemo/new-pretext-project/source/main.ptx
INFO    : string parameters passed to extraction stylesheet: {'publisher': '/home/sean/slidemo/new-pretext-project/publication/publication.ptx'}
INFO    : XSL conversion of /home/sean/slidemo/new-pretext-project/source/main.ptx by /home/sean/.ptx/2.5.2/core/xsl/extract-asymptote.xsl
INFO    : successful application of /home/sean/.ptx/2.5.2/core/xsl/extract-asymptote.xsl
INFO    : copying source file img-asymptote.asy
INFO    : converting /tmp/ptx-quhx906p/img-asymptote.asy to /tmp/ptx-quhx906p/img-asymptote.html
INFO    : converting /tmp/ptx-quhx906p/img-asymptote.asy to /tmp/ptx-quhx906p/img-asymptote.svg
WARNING : the Asymptote output /tmp/ptx-quhx906p/img-asymptote.svg was not built
             Perhaps your code has errors (try testing in the Asymptote web app).
             Or your local copy of Asymtote may precede version 2.66 that we expect.
             In this case, not every image can be built in every possible format.

             Your Asymptote reports its version within the following:
             Asymptote version 2.87 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]

ENABLED OPTIONS:
V3D      3D vector graphics output
WebGL    3D HTML rendering
OpenGL   3D OpenGL rendering
SSBO     GLSL shader storage buffer objects
GSL      GNU Scientific Library (special functions)
FFTW3    Fast Fourier transforms
Eigen    Eigenvalue library
XDR      External Data Representation (portable binary file format for V3D)
CURL     URL support
LSP      Language Server Protocol
Readline Interactive history and editing
Sigsegv  Distinguish stack overflows from segmentation faults
GC       Boehm garbage collector
threads  Render OpenGL in separate thread

DISABLED OPTIONS:
INFO    : converting /tmp/ptx-quhx906p/img-asymptote.asy to /tmp/ptx-quhx906p/img-asymptote.png
INFO    : converting /tmp/ptx-quhx906p/img-asymptote.asy to /tmp/ptx-quhx906p/img-asymptote.pdf
INFO    : converting /tmp/ptx-quhx906p/img-asymptote.asy to /tmp/ptx-quhx906p/img-asymptote.eps
INFO    : Removing temporary directory /tmp/ptx-5hx2oz9o
INFO    : Removing temporary directory /tmp/ptx-quhx906p
INFO    : Building target web
INFO    : Building with custom xsl /home/sean/slidemo/new-pretext-project/xsl/slides.xsl
INFO    : Preparing to build into /home/sean/slidemo/new-pretext-project/output/web.
INFO    : XSL conversion of /home/sean/slidemo/new-pretext-project/source/main.ptx by /tmp/pretext_7du7_mwg/slides.xsl
INFO    : messages from the log for XSL processing:
INFO    : * ********************************************************************************
INFO    : * Conversion to reveal.js presentations/slideshows is experimental
INFO    : * Requests for additional specific constructions welcome
INFO    : * Additional PreTeXt elements are subject to change
INFO    : * ********************************************************************************
INFO    : successful application of /tmp/pretext_7du7_mwg/slides.xsl
INFO    : 
Success! Run `pretext view` to see the results.

INFO    : 
----------------------------------------------------
INFO    : While running pretext, the following errors occurred:

INFO    : (see log messages above or in the 'logs' folder for more information)
INFO    : ----------------------------------------------------
sean-fitzpatrick commented 1 month ago

One more thing to note (which you are probably already aware of): right now we can build slides using xsltproc or the CLI (with custom), but there is no slideshow target for the pretext/pretext script. I suppose that's where most of the work is needed to make slideshow into a CLI target.