PreTeXtBook / pretext-cli

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

Add CLI support for slides #779

Closed oscarlevin closed 1 month ago

oscarlevin commented 4 months ago

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

sean-fitzpatrick commented 3 months 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 3 months 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 3 months 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 3 months 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.

oscarlevin commented 1 month ago

Coming back to this at last. I don't recall if we decided anything at the workshop about what to do, especially relative to the pretext/pretext script. We could,

  1. Leave pretext/pretext as it is, but create a new "format" in the CLI called "slideshow" that calls core.html but passes pretext-revealjs.xsl as custom xsl.
  2. Add a slideshow function to pretext/pretext so the script can also build slides, and then use that with the CLI.

Any preference @rbeezer and @sean-fitzpatrick ?

sean-fitzpatrick commented 1 month ago

I think I added slide support in the pretext/pretext script this summer.

I could track down the PR if it helps. Rob added an issue to include the zip format and bundle up the CSS etc in _static but I ran out of summer before I could get to it.

oscarlevin commented 1 month ago

You are right @sean-fitzpatrick. Somehow I missed that when I searched (probably on an old branch). I'll work on getting full support for it in the CLI.

Should the format be revealjs or htmlslides or...? Ideas welcome.

oscarlevin commented 1 month ago

Completed in #829

sean-fitzpatrick commented 1 month ago

Looking forward to the next release!

I'm hoping to submit a fix for image sizing soon. The other outstanding item for slides is the issue posted by @rbeezer to package up the whole thing (including the stuff in _static) as a zip file.

But I don't remember if the CLI handles zip as an output format.

sean-fitzpatrick commented 1 month ago

Slides are one place where, in hindsight, I should have set things up on GitHub with a workflow to build slides every time I push, since one typically updates slides before each class, and transferring things over to a web server each time is one extra step I could have avoided...

sean-fitzpatrick commented 1 month ago

@oscarlevin this might require a new issue, but building the sample slideshow reveals one other problem with the CLI: Asymptote is built in all formats, and depending on the figure (e.g. if it is 3D) some formats will fail. For slides, I think the only outformat you want for Asymptote is html. (The html outformat will produce WebGL for 3D images, and SVG for 2D.)

oscarlevin commented 1 month ago

I am pretty sure the next release has just html as the output for asymptote in slides.