pretext devscript and revealjs

32 views
Skip to first unread message

Andrew Scholer

unread,
Jul 19, 2024, 12:46:08 PM (5 days ago) Jul 19
to prete...@googlegroups.com
I am struggling to get the pretext devscript to generate revealjs slideshows and am not sure if it is just user error or if it is missing.

I can build the sample-slideshow with the xsltproc recipe in the guide, and if I add a project file I can build with the CLI, but I can't find any set of options that works from the devscript. The main culprit appears to be lack of an appropriate format option.

If this isn't just user error, should that ability exist?

Andrew Scholer (he/him/his)
Computer Science Instructor/Program Chair
Chemeketa Community College

kcri...@gmail.com

unread,
Jul 19, 2024, 1:02:02 PM (5 days ago) Jul 19
to PreTeXt development
I am struggling to get the pretext devscript to generate revealjs slideshows and am not sure if it is just user error or if it is missing.

I can build the sample-slideshow with the xsltproc recipe in the guide, and if I add a project file I can build with the CLI, but I can't find any set of options that works from the devscript. The main culprit appears to be lack of an appropriate format option.


I'm working on some analogous stuff, and perhaps posted something related just now, so listening in.   I'm going to assume just missing, based on several other recent threads and #2159.  (Remember, it's technically experimental ...)  Probably it works in CLI because it mostly uses the html conversion.

On a closely related note, how do you use the pretext script to generate actual output in any format (sans CLI), anyway?  I am having a lot of difficulty finding that in the guide, neither in https://pretextbook.org/doc/guide/html/processing.html nor in https://pretextbook.org/doc/guide/html/pretext-script.html where one might expect that.  I know how to use the pretext script to get images, but this is the whole kit and caboodle.

Sean Fitzpatrick

unread,
Jul 19, 2024, 3:31:48 PM (4 days ago) Jul 19
to PreTeXt development
Building slides with the CLI is working well, but maybe not what you want if you're hacking the XSL.

With the devscript I would try using the reveal.js xsl, and using -f html.

Andrew Scholer

unread,
Jul 19, 2024, 3:52:23 PM (4 days ago) Jul 19
to prete...@googlegroups.com
Using the devscript, "-f html" ends up calling html() in pretext.py and it passes None as the result param to xsltproc() - that represents an assumption that the XSL should be directly outputting files. But the pretext-revealjs does not appear to function in that way so no HTML is written.

I've gotten in the habit of always using the devscript as the projects in the examples directory are not consistently set up to easily build with the CLI. And so there is one less layer of code to dig through when something isn't working the way I expect. :)

Since the examples are the documentation of how you actually do things, it feels like there should be one fairly simple, consistent process the examples that can be used to build any of the samples. Is there any appetite to add more devscript targets? Or make sure all the examples have valid and modern project files?

Andrew Scholer (he/him/his)
Computer Science Instructor/Program Chair
Chemeketa Community College

--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-dev/442c3747-def6-4510-86d2-95dd900a871en%40googlegroups.com.

Sean Fitzpatrick

unread,
Jul 19, 2024, 4:47:51 PM (4 days ago) Jul 19
to PreTeXt development
I think that last question is above my pay grade :-)

Running pretext -h (where pretext is the devscript, not the CLI) suggests that slideshow is not among the allowed output formats.
But I was able to build slides in either of the following ways:

1. With the CLI: pretext build web (using the default target set up by doing pretext new slideshow)
2. With xsltproc: I used the following command (for the sample-slideshow, in a folder called "slidemo")

xsltproc -o slides.html --stringparam publisher ~/slidemo/publication/publication.ptx  ~/github/pretext/xsl/pretext-revealjs.xsl ~/slidemo/source/main.ptx

This will place slides.html in whatever folder I run the command from. (Edit your paths accordingly...)

kcri...@gmail.com

unread,
Jul 20, 2024, 1:38:14 PM (4 days ago) Jul 20
to PreTeXt development
xsltproc -o slides.html --stringparam publisher ~/slidemo/publication/publication.ptx  ~/github/pretext/xsl/pretext-revealjs.xsl ~/slidemo/source/main.ptx

For now, this is all I use in doing any slideshow stuff, though the CLI does work okay if you massage some things - but as said above, not helpful if you are trying to change xsl. 

Rob Beezer

unread,
Jul 20, 2024, 7:39:27 PM (3 days ago) Jul 20
to prete...@googlegroups.com
With the recent resurgence of interest in slides, I have lost track of where
some things have been posted.

There is no Python code yet to simplify the use of xsl/pretext-reveal.xsl. So
right now, "xsltproc" is really your only option. (I don't think this should be
happening via the CLI!)

Can't tell if Sean is working on this, or something related. If so,

* It should look like the other routines, such as for HTML, PDF, EPUB, etc.
Similar (identical?) signature, correct handling of the publisher file, etc.

* There needs to be way to invoke this via pretext/pretext. Again, in the
style of all the other features.

* I think there is an option for building a slideshow with "local" Reveal
javascript - say when you are not sure the conference site will have good wifi.
We should mirror that optio, likely the same way other variants are handled
(e.g. four kinds of EPUB).

* Then,and only then, the CLI will be in a position to use this routine. (The
CLI does not "call" pretext/pretext [which is not named "devscript"].)

Rob

Sean Fitzpatrick

unread,
Jul 20, 2024, 7:44:34 PM (3 days ago) Jul 20
to PreTeXt development
There has been CLI support for awhile, using the "custom" target and extra xsl. 

It works reasonably well, with external and generated images handled correctly with managed directories. One tweak is needed to specify html as the outformat for asymptote.

I was tinkering with pretext/pretext for slides but didn't get it to work just yet, and my plane is about to take off. 

I'll take another crack at it next week.


--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.

Rob Beezer

unread,
Jul 20, 2024, 9:21:10 PM (3 days ago) Jul 20
to prete...@googlegroups.com
On 7/20/24 16:44, Sean Fitzpatrick wrote:
> There has been CLI support for awhile, using the "custom" target and extra xsl.
>
> It works reasonably well, with external and generated images handled correctly
> with managed directories. One tweak is needed to specify html as the outformat
> for asymptote.

I don't consider that support. A custom target, extra XSL, and a tweak.
Resulting in incomplete pull requests. ;-)

Developers should learn how to use the codebase directly, with as few "end user"
tools in play as possible.

Rob

Sean Fitzpatrick

unread,
Jul 21, 2024, 10:04:56 AM (3 days ago) Jul 21
to PreTeXt development
On Monday I'll try to get the devscript to build slides. And I'll try not to put any tabs in the Python files.

--
You received this message because you are subscribed to the Google Groups "PreTeXt development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pretext-dev...@googlegroups.com.

Sean Fitzpatrick

unread,
Jul 22, 2024, 11:27:39 AM (2 days ago) Jul 22
to PreTeXt development
Here are the changes I made to the devscript. This is producing slides for me, including copying over external and generated image files.

But it's possible I've made a mistake or overlooked something, so I'd appreciate if another set of eyes (belonging to someone better at Python than me) can look this over and/or test.
I didn't include a zip option. Not sure if that's desirable.

In pretext/pretext/pretext:

Below line 365, add new line 366:
("revealjs", "reveal.js HTML slide format"),

Below line 740, add:
        elif args.format == "revealjs":
            ptx.revealjs(
                xml_source,
                publication_file,
                stringparams,
                args.xmlid,
                "revealjs",
                extra_stylesheet,
                out_file,
                dest_dir,
            )

In pretext/pretext/pretext.py, below line 3637, add:


def revealjs(
    xml, pub_file, stringparams, xmlid_root, file_format, extra_xsl, out_file, dest_dir
):
    """Convert XML source to reveal.js HTML file"""

    # to ensure provided stringparams aren't mutated unintentionally
    stringparams = stringparams.copy()

    # Consult publisher file for locations of images
    generated_abs, external_abs = get_managed_directories(xml, pub_file)

    # names for scratch directories
    tmp_dir = get_temporary_directory()

    # support publisher file, and subtree argument
    if pub_file:
        stringparams["publisher"] = pub_file
    if xmlid_root:
        stringparams["subtree"] = xmlid_root
    # Optional extra XSL could be None, or sanitized full filename
    if extra_xsl:
        extraction_xslt = extra_xsl
    else:
        extraction_xslt = os.path.join(get_ptx_xsl_path(), "pretext-revealjs.xsl")

    # place managed directories - some of these (Asymptote HTML) are
    # consulted during the XSL run and so need to be placed beforehand
    copy_managed_directories(tmp_dir, external_abs=external_abs, generated_abs=generated_abs)

    # place CSS and JS in scratch directory
    copy_html_css_js(tmp_dir)

    # Write output into temporary directory
    log.info("converting {} to HTML in {}".format(xml, tmp_dir))
    xsltproc(extraction_xslt, xml, out_file, tmp_dir, stringparams)

    if file_format  == "revealjs":
        # with multiple files, we need to copy a tree
        # see comments at  copy_build_directory()
        # before replacing with  shutil.copytree()
        copy_build_directory(tmp_dir, dest_dir)
        derivedname = get_output_filename(xml, out_file, dest_dir, ".html")
    else:
        raise ValueError("PTX:BUG: HTML file format not recognized")

Rob Beezer

unread,
Jul 22, 2024, 12:31:50 PM (2 days ago) Jul 22
to prete...@googlegroups.com
Dear Sean,

Nobody is going to test this by chasing down line numbers and cutting/pasting.

Please formulate the changes as a PR you can advertise on this thread.

Rob
> https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com
> <mailto:pretext-dev...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com <https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Sean Fitzpatrick

unread,
Jul 22, 2024, 12:42:57 PM (2 days ago) Jul 22
to PreTeXt development

Steven Clontz

unread,
Jul 22, 2024, 2:00:55 PM (2 days ago) Jul 22
to PreTeXt development
Clarification: PreTeXt-CLI doesn't support slides (unless it was added last week when I was away), but it does support a `custom` format that provides some sugar for importing pretext XSL into your own XSL files and building them to a location alongside other formats. We have a `pretext new slideshow` that aims to illustrate this with slides, but I don't think we should implement `<target format="slides"/>` until there's support in core Python routines.

Rob Beezer

unread,
Jul 22, 2024, 2:13:58 PM (2 days ago) Jul 22
to prete...@googlegroups.com
If slides are not supported, then why is there a "pretext new slideshow"?

Perhaps custom formats, extra XSL, and necessary tweaks should be in the
documentation, and not in a tempting place for new authors.
> > log.info <http://log.info>("converting {} to HTML in {}".format(xml,
> https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect> <https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDAyMC5iZWV6ZXI.1721524868%40quikprotect>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "PreTeXt development" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send an email
> > to pretext-dev...@googlegroups.com
> > <mailto:pretext-dev...@googlegroups.com>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com <https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com> <https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/pretext-dev/d28592c3-9872-4234-8f9f-ca9371859f20n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-dev...@googlegroups.com
> <mailto:pretext-dev...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/40017fd8-534f-4d62-a65b-37b3b97a4a1cn%40googlegroups.com <https://groups.google.com/d/msgid/pretext-dev/40017fd8-534f-4d62-a65b-37b3b97a4a1cn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Jul 22, 2024, 2:27:00 PM (2 days ago) Jul 22
to prete...@googlegroups.com
Removing this seems reasonable. I forgot the original rationale, but maybe it was "Steven wants to show off custom format support and folks keep asking how to make a slideshow". @Oscar?


Oscar Levin

unread,
Jul 22, 2024, 2:50:41 PM (2 days ago) Jul 22
to PreTeXt development
The CLI supports custom formats, which currently includes slides (to the extent that pretext supports slides, which it does, and that support is getting better).  The CLI does not support "slides" one of its built in formats, but that will change soon (once pretext/pretext has a slides function and after I'm done with updates to DMOI in a couple weeks).

I don't see any reason to make any changes to which templates exist now.  As Sean has said, using slides in the CLI works just fine right now.

Sean Fitzpatrick

unread,
Jul 22, 2024, 2:51:46 PM (2 days ago) Jul 22
to PreTeXt development
The point of the pull request is to add slides into core Python routines...

Reply all
Reply to author
Forward
0 new messages