getting asymptote to play with CLI

47 views
Skip to first unread message

Steven Clontz

unread,
Jan 31, 2022, 2:55:28 PM1/31/22
to PreTeXt development
I thought it might be prudent to add a sageplot and asymptote to our default book produced by pretext new. But I'm getting errors when building asymptote diagrams in HTML.


Errors:

PTX: converting Asymptote diagrams from /home/user/new-pretext-project/source/main.ptx to HTML graphics for placement in /home/user/new-pretext-project/generated-assets/asymptote with method "server"
PTX: extracting Asymptote diagrams from /home/user/new-pretext-project/source/main.ptx
PTX: string parameters passed to extraction stylesheet: {'publisher': '/home/user/new-pretext-project/publication/publication.ptx', 'sageplot.fileformat': 'svg'}
PTX: XSL conversion of /home/user/new-pretext-project/source/main.ptx by /home/user/pretext-cli/pretext/static/xsl/extract-asymptote.xsl
PTX: converting cflag.asy to cflag.html

Now building HTML into /home/user/new-pretext-project/output/html

PTX: discovering source file's directory name: /home/user/new-pretext-project/source
PTX: verifying and expanding input directory: /home/user/new-pretext-project/source/../generated-assets
PTX: input directory expanded to absolute path: /home/user/new-pretext-project/generated-assets
PTX: verifying and expanding input directory: /home/user/new-pretext-project/source/../assets
PTX: input directory expanded to absolute path: /home/user/new-pretext-project/assets
PTX: converting /home/user/new-pretext-project/source/main.ptx to HTML in /tmp/tmpyjrg1tra
PTX: XSL conversion of /home/user/new-pretext-project/source/main.ptx by /home/user/pretext-cli/pretext/static/xsl/pretext-html.xsl
PTX: Failed application of /home/user/pretext-cli/pretext/static/xsl/pretext-html.xsl, with messages:
    *  failed to load external entity "/home/user/new-pretext-project/source/generated/asymptote/cflag.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/cflag.html" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/cflag.html" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  failed to load external entity "/home/user/new-pretext-project/source/generated/asymptote/cflag.html"
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/cflag.html" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.
    *  PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/cflag.html" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its height cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.


Looking back at https://github.com/PreTeXtBook/pretext-cli/issues/190 I think OP's concern about remote/local was a red herring: this is a general bug that someone with more knowledge of the Asymptote build process hopefully can help fix.

N.B. if I am reading this right, and PreTeXt core Python or XSL breaks unless the generated subfolder is a subdirectory of main.ptx, this needs to be fixed. Generated images have no business being inside the directory with source.

Steven Clontz

unread,
Jan 31, 2022, 3:02:26 PM1/31/22
to PreTeXt development
mostly unrelated ps: is there any documentation of what the @aspect attribute on 3d sageplots wants? width:height? a float ratio for height/width? I'm just finding documentation that "aspect" needs to be specified, somehow.

Sean Fitzpatrick

unread,
Jan 31, 2022, 3:03:26 PM1/31/22
to prete...@googlegroups.com
There was a change a couple of years ago, and I don't quite recall why we do this, but Rob can explain.

If your source has
<image xml:id="cflag">
  <description>...</description>
  <asymptote>
    ...
  </asymptote>
</image>

the pretext/pretext script with outformat HTML builds the HTML file, and then you have to put it in two places: output/html/images, and source/images

If I remember right, the copy in source/images is needed during the HTML build, because XSL reads the last lines from the Asymptote-generated XSL file. Those lines look like:

<body style="overflow: hidden;" onload="webGLStart();">
<canvas id="Asymptote" width="201" height="201" style="border: none; cursor: pointer;">
</canvas>
</body>

The dimensions are there, and this is needed for setting the image container in the HTML.
--
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/f7ab0eb4-c1c2-411c-8e31-a05440c018bcn%40googlegroups.com.

Steven Clontz

unread,
Jan 31, 2022, 3:10:30 PM1/31/22
to PreTeXt development
That's no good. Python should be reading this file and supplying it to XSLT as a param, if XSLT cannot handle this itself. There's no reason to litter source with the product of a diagram build.

Sean Fitzpatrick

unread,
Jan 31, 2022, 3:18:54 PM1/31/22
to prete...@googlegroups.com
Have a look at pretext-html.xsl, starting at line 6249.
This is where it reads the dimensions from the existing Asymptote html file.

Rob Beezer

unread,
Jan 31, 2022, 3:37:55 PM1/31/22
to prete...@googlegroups.com
@aspect may no longer be needed (or even respected). We query the image file
for dimensions as Sean has pointed out.

Output file may be where you don't like it because you put it there? ;-)

Should only be one copy, and with managed directories it should be put there
(very new, likely beyond what you are using?), but at a minimum, if you manually
put it into the right place, it should be queried and displayed correctly.

Good examples in the sample article - check there? Section 9.

Rob
>>> <https://groups.google.com/d/msgid/pretext-dev/f7ab0eb4-c1c2-411c-8e31-a05440c018bcn%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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%40googlegroups.com
>> <https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%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/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.com
> <https://groups.google.com/d/msgid/pretext-dev/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Jan 31, 2022, 3:57:27 PM1/31/22
to PreTeXt development
@aspect question is about sageplot, not asymptote.

The file is being built to the right place and I know this because it shows up when you view the built HTML. I'm referring specifically to this error:

PTX:ERROR:   the Asymptote diagram produced in "generated/asymptote/cflag.html" needs to be available relative to the primary source file, or if available it is perhaps ill-formed and its width cannot be determined (which you might report as a bug).  We might be able to proceed as if the diagram is square, but results can be unpredictable.

PreTeXT-CLI doesn't set this directory as a subdirectory of the source PreTeXt file because doing so is a bad idea for abstracting this whole diagram generation process away from authors, making clean Git repositories, etc. So this requirement (if it indeed is a requirement) should be removed.

Hmm. Saying this I realized that the error says "generated/asymptote/cflag.html", but maybe it should be looking for "../generated-assets/asymptote/cflag.html" ? https://github.com/PreTeXtBook/pretext-cli/blob/main/templates/book/publication/publication.ptx#L12 

Sean Fitzpatrick

unread,
Jan 31, 2022, 4:58:22 PM1/31/22
to PreTeXt development
The Asymptote error sounded to me like it was looking for the copy in the source folder to read the dimensions.

But with managed directories this could become redundant. As long as images are built before HTML, can we just look in html/images instead?

Or you could write the dimensions to some auxiliary file, I guess.

Rob Beezer

unread,
Jan 31, 2022, 5:04:51 PM1/31/22
to prete...@googlegroups.com
On 1/31/22 12:57 PM, Steven Clontz wrote:
> @aspect question is about sageplot, not asymptote.

See very last paragraph of 17.1.

https://pretextbook.org/examples/sample-article/html/section-video.html

(Yes, there are some goofed-up videos in there. Not now.)

Rob Beezer

unread,
Jan 31, 2022, 5:13:04 PM1/31/22
to prete...@googlegroups.com
The image file built by Asymptote contains the dimensions of the image that
results from the author's Asymptote source. So we can spare the author the need
to (a) determine the shape, (b) compute an aspect ratio, (c) specify the ratio
in the source.

It is a limitation of XSL that "opening" an XML file is a very basic operation.
The location is relative to the XML source or relative tot he stylesheet being
employed.

Perhaps a by-product of the Asymptote build is an XML file of dimensions. But I
don't see that addressing your philosophical objections, since now we have to
read that file *somehow* (in the pre-processor?).

Rob

On 1/31/22 12:57 PM, Steven Clontz wrote:
> <https://groups.google.com/d/msgid/pretext-dev/f7ab0eb4-c1c2-411c-8e31-a05440c018bcn%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pretext-dev/f7ab0eb4-c1c2-411c-8e31-a05440c018bcn%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.
> >> To view this discussion on the web visit
> >>
> https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%40googlegroups.com>
>
> >>
> <https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pretext-dev/1acc7979-aa8f-47cb-910e-a33f1a4e51a3n%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/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.com
> <https://groups.google.com/d/msgid/pretext-dev/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.com>
>
> >
> <https://groups.google.com/d/msgid/pretext-dev/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pretext-dev/2f8542fd-5e4d-b212-0948-51c23859546b%40gmail.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/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Jan 31, 2022, 5:33:04 PM1/31/22
to PreTeXt development
Unless I'm mistaken, XSL should know where to find a copy of the products of Asymptote because it has access to the publication file used by Python to  (in CLI, this is `../generated-assets/asymptote/` by default, relative to the main source file): https://github.com/PreTeXtBook/pretext-cli/blob/main/templates/book/publication/publication.ptx#L15 So what's keeping us from using that?

Rob Beezer

unread,
Jan 31, 2022, 6:48:24 PM1/31/22
to prete...@googlegroups.com
Dear Steven,

I thought we *were* doing this. ;-)

Find:

<xsl:template match="image[asymptote]" mode="image-inclusion">

in pretext-html.xsl.

Maybe because the sample article uses "generated" in the original source
location, I just got lucky. We *are* consulting the managed directories.

The document() function a few lines later is referencing the "original" XML
source (source/main.ptx in CLI-speak) and so "../generated-assets" should point
to the correct place?

Any insights? Not clear to me where we have a disconnect with the CLI pipeline.

(If it is not obvious, my debugging budget for the day is overdrawn. :-( )

Maybe I'll go mindlessly deprecate some old string parameters....

Rob
> <https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%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/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegroups.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Jan 31, 2022, 9:03:29 PM1/31/22
to PreTeXt development
I can confirm that Asymptote image builds seem to only work if and only if @generated="generated". 

Steven Clontz

unread,
Jan 31, 2022, 9:05:18 PM1/31/22
to PreTeXt development
I mean, I should clarify, that's with the CLI. I'd appreciate a quick check with the pretext/pretext script, but I cannot imagine how we might be mangling this when everything else in the publication file is handed off just fine.

Rob Beezer

unread,
Feb 1, 2022, 1:19:15 PM2/1/22
to prete...@googlegroups.com
Dear Steven,

Yes, I got lucky. :-( Conflated the "produced" HTML (for examination) and the
"output" HTML (for viewing). Including within the error message, which was
worse than no message at all.

Fixed. Even had the publisher variable I needed already.

https://github.com/rbeezer/mathbook/commit/2c724c309adcb9ce32ac19963db5bb10d52f0cdd

@Sean - I *think* this will still behave absent the managed directory scheme, so
long as any copy/move of image files does not do too much renaming or
reorganization. I've tested as much as I can, but I don't have a good example
of this anymore with Asymptote 3D in it. Can you test and report? Check
building without error AND rendering without files missing. Error messages are
improved. ;-)

Thanks, Steven, for sticking with this one. Over to you, for one more test, if
you are willing.

Rob
> <https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%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/9e1ac294-b8a8-4a21-866c-9838ae8e9fa1n%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-dev/9e1ac294-b8a8-4a21-866c-9838ae8e9fa1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Sean Fitzpatrick

unread,
Feb 1, 2022, 1:27:13 PM2/1/22
to prete...@googlegroups.com
@Rob: it might be awhile until I manage to test. We are very likely
going on strike next week, so I'm trying to clear out as much
teaching-related work as I can right now.

Although our union has decided we are not "striking against research",
they apparently consider open textbooks to be service work rather than
scholarly activity, so I am expected to disengage for the duration of
the strike.

I'll see if I can squeeze in an Asymptote build this afternoon.

Are you looking for just the old style Asymptote run (pretext -c asy -f
html etc...) or the HTML build via xsltproc that comes after that?

APEX is not yet set up to build with pretext-cli or for a full build
with pretext/pretext.

Steven Clontz

unread,
Feb 1, 2022, 1:35:15 PM2/1/22
to prete...@googlegroups.com
Whatever you can do quickest should be useful information I think. I'll test with cli hopefully later today.

You received this message because you are subscribed to a topic in the Google Groups "PreTeXt development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pretext-dev/ZBq3wGzqkTE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pretext-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-dev/019edc6f-1aa8-eb82-e593-40adffc54e7c%40gmail.com.

David Farmer

unread,
Feb 1, 2022, 1:38:40 PM2/1/22
to prete...@googlegroups.com

Writing a textbook is teaching.

Advancing the infrastructure to create scholarly documents is research.
> >>https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegroup
> s.com
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com>
> >>
> >>          >
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com>>
> >>
> >>          >
> >>          > >
> >>          >
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com?utm_medium=email&utm_source=footer
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com?utm_medium=email&utm_source=footer>
> >>
> >>          >
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.com?utm_medium=email&utm_source=footer
> >><https://groups.google.com/d/msgid/pretext-dev/955c6170-03ad-4a9e-a2f4-fc80112b7812n%40googlegrou
> ps.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/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegroup
> s.com
> >><https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegrou
> ps.com>
> >>
> >>          >
> >><https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegrou
> ps.com?utm_medium=email&utm_source=footer
> >><https://groups.google.com/d/msgid/pretext-dev/46220f88-7f58-4ac5-af7e-1d65f15cdd1en%40googlegrou
> ps.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/9e1ac294-b8a8-4a21-866c-9838ae8e9fa1n%40googlegroup
> s.com
> >><https://groups.google.com/d/msgid/pretext-dev/9e1ac294-b8a8-4a21-866c-9838ae8e9fa1n%40googlegrou
> ps.com?utm_medium=email&utm_source=footer>.
> >>
> >
>
> --
> You received this message because you are subscribed to a topic in the Google Groups
> "PreTeXt development" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/pretext-dev/ZBq3wGzqkTE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> pretext-dev...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/019edc6f-1aa8-eb82-e593-40adffc54e7c%40gmail.com.
>
> --
> 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 visithttps://groups.google.com/d/msgid/pretext-dev/CAOWT6TjmW_FrzPOZRciabuBMz2%3DH2Z0Pm4fMsns1uhSVfTnS
> -Q%40mail.gmail.com.
>
>

Steven Clontz

unread,
Feb 1, 2022, 1:47:39 PM2/1/22
to PreTeXt development
I agree with David. Follow your conscience, but here's my current argument for edtech-dev-as-scholarship: https://stevenclontz.github.io/2022-spda-application/background.html#background (For whatever it's worth, my institution yesterday officially awarded me a small fellowship this summer based on that proposal, so someone bought the argument at least.)

Rob Beezer

unread,
Feb 1, 2022, 1:49:59 PM2/1/22
to prete...@googlegroups.com
Dear Sean,

Maybe we can find a PreTeXt project that is a tough nut to crack that you can
call "research" and not textbook authoring? ;-) Good luck with the labor action.

I don't think it is xsltproc or pretext/pretext that matters. And Steven
has the CLI covered.

Its the *management* of your files/images that matters. We are OK (I think)
with managed directories.

BUT, your *build* needs to find an Asymptote HTML file to inspect dimensions,
and then *where/how you place output* needs to find the file (duh). The first
was consuilting the latter, which may have coincidentally had the same relative
path. In other words, anybody using an "images" subdirectory of their source
should be OK. I think.

Any mismatch or fancy footwork will be addressed with "move to the managed
directory scheme, we can't predict what you might be doing" ;-)

Thanks,
Rob

Sean Fitzpatrick

unread,
Feb 1, 2022, 1:58:16 PM2/1/22
to prete...@googlegroups.com
Dear Rob,

For today, at least, I can work on this. Maybe even while sitting in on
the union meeting that is about to begin on Zoom :-)

What I am wondering is whether it is a useful test to try to build
Asymptote (and HTML) with my current setup for APEX (which does not
involve managed directories).

Right now I have

ptx/images/
and
output/html/images

where ptx is my source folder.

My Asymptote build command looks like:

  pretext -vv -p
~/Documents/APEXCalculusPTX/publication/publication.xml -c asy -f html
-d ~/Documents/APEXCalculusPTX/ptx/images
~/Documents/APEXCalculusPTX/ptx/apex.ptx
  cp -r ~/Documents/APEXCalculusPTX/ptx/images
~/Documents/APEXCalculusPTX/output/html/

(I first build everything into a subdirectory of my source folder, and
then copy it all to output.)

HTML then builds with a pretty standard xsltproc call.

I can run these as is, or modify if needed.

Rob Beezer

unread,
Feb 1, 2022, 2:13:24 PM2/1/22
to prete...@googlegroups.com
Can't be certain, which is why a test will be worthwhile. ;-) But,

(a) that looks likely to succeed

(b) yes, run like that, no changes

You'll get an error from teh XSL code if the aspect ratio can't be determined,
and an error in your web browser if the image file is not found (Firefox,
anyway). Both should have paths/filenames in them.

Rob

Sean Fitzpatrick

unread,
Feb 1, 2022, 2:16:22 PM2/1/22
to prete...@googlegroups.com
OK. Looks like I'm getting a clean run from Asymptote, using John's server.
Still going, due to number of images to process.

HTML takes 2-3 hours, so I'll have a report later this afternoon. (Or
sooner, if it fails.)

Sean Fitzpatrick

unread,
Feb 1, 2022, 2:17:35 PM2/1/22
to prete...@googlegroups.com
Is XSL still looking in the source folder for the aspect ratio, or is it
now looking in html/images?

On 2022-02-01 12:13 p.m., Rob Beezer wrote:

Rob Beezer

unread,
Feb 1, 2022, 2:30:08 PM2/1/22
to prete...@googlegroups.com
Absent managed directories, I think it is looking in the same place as before.
Wherever that is. ;-)

In other words, I think teh code changes will have zero effect. Diffs
before/after of output say so, but that does not confirm the XSL inspection bit.

> HTML takes 2-3 hours

I hope the union meeting does not take that long. ;-)

Rob

Sean Fitzpatrick

unread,
Feb 1, 2022, 2:46:00 PM2/1/22
to prete...@googlegroups.com
OK. Didn't need to wait for the HTML build to finish. Current changes
not backward-compatible.
For each Asymptote figure, I'm getting an error like:

PTX:ERROR:   the Asymptote diagram produced in "" needs to be available
relative to the primary source file, or if available it is perhaps
ill-formed and its height cannot be determined (which you might report
as a bug).  We might be able to proceed as if the diagram is square, but
results can be unpredictable.
warning: failed to load external entity
"/home/sean/Documents/APEXCalculusPTX/ptx/img_sa2a_3D.html"

But this is easy to diagnose: it's looking for all of the image html
files to be directly in the source folder.
It's looking for
/home/sean/Documents/APEXCalculusPTX/ptx/img_sa2a_3D.html but that file
is in
/home/sean/Documents/APEXCalculusPTX/ptx/images/img_sa2a_3D.html

I'm going to run xsltproc again after moving all the images out of the
images/ folder and up one level.
But as a long term solution I don't like it: I don't want 700 HTML files
cluttering up my source folder!

Steven Clontz

unread,
Feb 1, 2022, 2:50:42 PM2/1/22
to PreTeXt development
Updating to most recent mathbook commit allows our CLI template book where generated="../generated-assets" to build with no Asymptote errors.

With that, I'll be bumping to 0.6rc0 and get feedback from folks.

Rob Beezer

unread,
Feb 1, 2022, 3:05:41 PM2/1/22
to prete...@googlegroups.com
Got it. Thanks. @Steven - this should not stop you.

> But as a long term solution I don't like it

Me either! I see where to add a change, but it looks like it'll have some
fall-out for EPUB, so I'll need to study that case also.

Thanks for the test. I suspect it'll behave after the move.

(The managed directories take all of this directory structure, moves, copies,
etc. out of your hands and it just works. Perhaps you could "research" the
effectiveness of this device/invention for open source publishers next week. ;-) )

Rob

Sean Fitzpatrick

unread,
Feb 1, 2022, 3:08:48 PM2/1/22
to prete...@googlegroups.com
So far, with the move, the only warnings I'm getting are due to the fact
that I haven't yet added @visual to my URLs.

Moving APEX to managed directories is on the to-do list. :-)

Sean Fitzpatrick

unread,
Feb 1, 2022, 5:03:49 PM2/1/22
to prete...@googlegroups.com
Clean run once the files were moved up a level.

Extra incentive to set up managed directories and/or pretext-cli because
if those don't get cleaned out after every build...
(OK, yes I can add a bash script to scrub all the html files in my
source but I should be moving to the CLI anyway, so...)

On 2022-02-01 1:05 p.m., Rob Beezer wrote:

Steven Clontz

unread,
Feb 1, 2022, 5:11:44 PM2/1/22
to PreTeXt development
TBH I'm not aware of any specific "big" projects that use the CLI unless Oscar's wired up his discrete book. So if you're willing to take the plunge synchronously with me sometime, it'd be a good exercise in seeing how to wire up legacy projects, rather than what the CLI is really good at (quickly creating and managing new projects without any opinionated makefiles, etc).

Rob Beezer

unread,
Feb 2, 2022, 8:32:17 PM2/2/22
to prete...@googlegroups.com
> I've tested as much as I can, but I don't have a good example of this anymore with Asymptote 3D in it.

Well, I lied. ;-) I saw the Showcase Article scroll by last night as part of
my website build script. Piles of Asympote-HTML not-found errors. (It is not
so bad, the images are OK, but there is just too much space around them due to a
bad aspect ratio.) So I do have a test case. And with that I've put in a fix.

Subsection 3.2: Images and Diagrams from Asymptote
https://pretextbook.org/examples/showcase/html/latex-image.html#subsection-6

Notice that the area-under-the-bell-curve graphic is no longer sitting in a
square box (extra whitespace above and below). ;-)

Fix only affects the case when not using the managed directories scheme.
(Hence, no change for the CLI.)

@Sean - a final (?) run with the images in their former location? Overnight?

Rob

Sean Fitzpatrick

unread,
Feb 3, 2022, 5:56:32 PM2/3/22
to prete...@googlegroups.com
Pulled and ran the html build with everything tucked away in ptx/images
No errors! (yay!)

A few warnings that reflect how I haven't had time to adapt to recent
changes ;-)

Rob Beezer

unread,
Feb 3, 2022, 6:09:16 PM2/3/22
to prete...@googlegroups.com
On 2/3/22 2:56 PM, Sean Fitzpatrick wrote:
> Pulled and ran the html build with everything tucked away in ptx/images
> No errors! (yay!)

Thanks very much!

> A few warnings that reflect how I haven't had time to adapt to recent changes ;-)

You might be the only person who has as much pain as I do when changes are
necessary. ;-)

Rob
Reply all
Reply to author
Forward
0 new messages