FITB: fix host-platform for extracting dynamic substitutions
When trying to build a complete target (e.g. sample-book) for runestone, the CLI calls the extract dynamic substitutions routine with the target platform as runestone. However, the stand-alone pages that are produced for extraction are actually being hosted locally and so need to use host-platform as web.
Modified pretext.py to override the stringparam for host-platform for this call.
Question: Should I have made a copy of the stringparams and modified the entry in a copy? I just realized that the CLI isn't calling the pretext/pretext script for each resource — it is sequentially calling internal functions with the stringparams as it works through the resource list. So modifying the stringparams internally in the dynamic_substitutions function may have a downstream side-effect.
@oscarlevin might have insight on this
@dbrianwalton when I looked at your PR my first thought was, II hope the stringparam dictionary isn't global so that this messes up later actions. My hunch is you should make a copy.
Thanks @bnmnetp for confirming.
Yes, almost(?) all the functions that manipulate the stringparams make a copy first
Oscar and I were just chatting during drop in... Is generating dynamic substitutions for a Runestone build even necessary? If so, then Oscar will want to add a check to ensure that playwright is installed.
I really don't think it should be required for Runestone since that is a dynamic build, not a static build. It shouldn't really be required for a web build either. During the assembly pre-processor stage presumably while numbering is being generated, the extractions are being looked at (because it is a layer in the assembly for a static build) but never actually used. So if dynamic substitutions are not present, there would be some warnings generated but I don't think it interrupts the process.
I just tried to build sample-book with pretext/pretext/pretext (not CLI) with the substitutions were not available. I used the noparts publication file with format html and platform runestone and I didn't see that it ever looked for the substitutions. Maybe I was remembering something else. [When I tried using the runestone publication file, my installation choked on something related to a custom theme, which is why I tried noparts]
What would be helpful in terms of the CLI is to know which formats really require the dynamic_substitution function to run. Currently this is set up to be required for all formats. But if we can remove it from HTML, that would be great.
On Mon, Jun 16, 2025 at 10:37 AM dbrianwalton @.***> wrote:
dbrianwalton left a comment (PreTeXtBook/pretext#2557) https://github.com/PreTeXtBook/pretext/pull/2557#issuecomment-2977310205
I just tried to build sample-book with pretext/pretext/pretext (not CLI) with the substitutions were not available. I used the noparts publication file with format html and platform runestone and I didn't see that it ever looked for the substitutions. Maybe I was remembering something else. [When I tried using the runestone publication file, my installation choked on something related to a custom theme, which is why I tried noparts]
— Reply to this email directly, view it on GitHub https://github.com/PreTeXtBook/pretext/pull/2557#issuecomment-2977310205, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRUBFAKVVHY4DOLGN3P2JL3D3XEJAVCNFSM6AAAAAB7GNRJKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNZXGMYTAMRQGU . You are receiving this because you were mentioned.Message ID: @.***>
The dynamic formats, html and runestone, do not need the substitutions because they run the actual javascript.
All static formats (everything else?) will need the substitutions.
Perfect. Then I'll make the change for the CLI so there will be no need for playwright on Runestone builds.
On Mon, Jun 16, 2025 at 1:49 PM dbrianwalton @.***> wrote:
dbrianwalton left a comment (PreTeXtBook/pretext#2557) https://github.com/PreTeXtBook/pretext/pull/2557#issuecomment-2977906778
The dynamic formats, html and runestone, do not need the substitutions because they run the actual javascript.
All static formats (everything else?) will need the substitutions.
— Reply to this email directly, view it on GitHub https://github.com/PreTeXtBook/pretext/pull/2557#issuecomment-2977906778, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABRUBFET4MHOXVCD5Y22BVT3D4NV3AVCNFSM6AAAAAB7GNRJKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNZXHEYDMNZXHA . You are receiving this because you were mentioned.Message ID: @.***>
We (@bnmnetp and @sean-fitzpatrick and I) just discovered that even though the dynamic substitutions are not needed in Runestone, the dynamic_substitutions.xml file apparently is for the preprocessor to generate other assets. I'll follow up on the -dev thread here: https://groups.google.com/g/pretext-dev/c/Ij8TJdKxX6U/m/zxSigmr-AgAJ
This PR got hung up because I would like the copy authored identically to the numerous other places where it is routinely done. In the extreme (not now) it could be a utility function. Brian and I discussed this in Drop-In, but I may not have been clear enough.
Yes, @oscarlevin, this file should only be consulted for output formats with "dynamic" exercise styles, which means broadly interactive, not Brian's use of the word dynamic. And only consulted if the source has any of Brian's FITB exercises.
In other words, JS-enabled HTML output formats only.
Sorry, @rbeezer, I did misunderstand. I had copied what was being done in the cli. I'll shortly push another commit that matches the pretext.py model.
Thanks, @dbrianwalton. Sorry to be picky - it just helps to make maintenance easier and thus makes the code less buggy.
It should look much cleaner now.
Yes, thanks for the quick work. Should be able to merge soon after I am back home. Landing right now
OK, down to a copy, and then a reset on the host platform, so we aren't all mixed-up with Runestone id's. Thanks for working this one out.
Still need to sort out the dynamic and static variants of the various extraction templates.