sage cells not working in PreTeXt books

41 views
Skip to first unread message

David Farmer

unread,
Mar 4, 2022, 10:31:26 AM3/4/22
to sage...@googlegroups.com

The console says

Uncaught ReferenceError: $ is not defined

Some examples on this page:

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

The sample cell on https://sagecell.sagemath.org/ is working .

Things were working yesterday.


Andrey Novoseltsev

unread,
Mar 4, 2022, 10:48:25 AM3/4/22
to sage-cell
This is quite unfortunate. The page you linked has
<script>$(function () {
on line 84, i.e. it tries to access jQuery, but had no explicit jQuery loaded. We used to have instructions with these dollar signs and you were supposed to load jQuery and embedded_sagecell. Your page loads only the latter, but still tries to use jQuery. So on the one hand we can say that it is your fault and you need to fix it, but how many other such pages are out there?

There were problems with relying on loading our own jQuery - some pages wanted to use it for other purposes and there were versions-settings incompatibilities. To address it, we started including "private" jQuery, but I think the way it worked was "use this one internally and set it as an external as well unless external is already loaded". With the recent changes we don't expose our jQuery at all, so users have to load it explicitly if they rely on it. (And it is NOT needed to make calls to sagecell.)

So, what should we do?
1) Stick with the current situation - if you call jQuery explicitly, then load it explicitly as well.
2) Keep indefinitely for backward compatibility the setting of global jQuery if it was not loaded.

Rob Beezer

unread,
Mar 4, 2022, 10:58:21 AM3/4/22
to sage...@googlegroups.com
Certainly PreTeXt is running with old directions, which have continued to function. I can't recall how or when I would have missed an announcement of a change.

I think any PreTeXt book with Sage cells will now lose that functionality until we change, and publishers can rebuild and rehost their output.

Is there a path for us to get everybody up to speed without a sudden disruption?

Rob

David Farmer

unread,
Mar 4, 2022, 11:05:32 AM3/4/22
to sage-cell

Was this a recent change? PreTeXt has been doing it that way
for years.

At minimum I would like the current setup to continue functioning
through this academic year. Here is one of the books we are using,
and it does explicitly load jQuery:

https://books.aimath.org/aata/sets-sage.html

That page is a bit more than 2 years old, and I think it was working
until today.

We can re-evaluate during the summer. Getting rid of the jQuery
dependence is not a problem. The issue is that 100 textbooks are
written in PreTeXt. Not all use sage cells, but all of them have it
working as in the link above.

David
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> sage-cell+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/883f71f2-8348-4c9b-8bc0-b50034724ad6n%40googlegroups.com.
>
>

Andrey Novoseltsev

unread,
Mar 4, 2022, 11:26:04 AM3/4/22
to sage-cell
The old instructions were:

load jQuery
load embedded_sagecell
use $(makeSagecell)

Then they changed to

load embedded_sagecell
use makeSagecell

while the page David linked is using a combo

load embedded_sagecell
use $(makeSagecell)

which kind of does not make sense, but continued to function. I will revert to it shortly for the time-being, do we want to keep it forever?

David Guichard

unread,
Mar 4, 2022, 11:35:10 AM3/4/22
to Andrey Novoseltsev, sage-cell
Hi--
Sort of off-topic, but I looked at both links that David included, and I don't even see sage cells. I tried both Firefox and Chrome, and Firefox with all addons disabled. The simple sage cells in my own books work fine.
-- David

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

Rob Beezer

unread,
Mar 4, 2022, 11:36:38 AM3/4/22
to sage-cell
A reversion would be very helpful. We can implement a correct procedure and ask publishers to rebuild before September 30. Would that work on your end?

Thanks for your prompt attention to this one!

Rob

David Farmer

unread,
Mar 4, 2022, 11:38:37 AM3/4/22
to sage-cell

Right: the sage cells are missing. That is the problem.
> To view this discussion on the web visithttps://groups.google.com/d/msgid/sage-cell/CADERMBQWTg6WZ%3DQitEi3F%3D8fk3EkcXF63gF5Ligs5w%2BgSk%3DN3g%40
> mail.gmail.com.
>
>

David Farmer

unread,
Mar 4, 2022, 11:47:38 AM3/4/22
to Rob Beezer, sage-cell

Is there some way that other JavaScript on that page
(meaning, JS that I control) can do something to allow that page
to work with the new setup on the server?

That way you could switch now and do not need to worry about
old pages breaking.
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/MTAwMDAzNy5iZWV6ZXI.1646411796%40quikprotect.
>

Andrey Novoseltsev

unread,
Mar 4, 2022, 1:32:47 PM3/4/22
to sage-cell
The issue is currently fixed by rolling back to https://github.com/sagemath/sagecell/commit/e382c614a287364c62343079ea295daf80b1d761 which was the last change necessary to work with Sage 9.5.

Fixing it is very easy - just do not wrap the calls with $(...). However, it is a fix that has to be applied to every page that followed mixed instructions. For the record, "new" instructions were posted in 2016: https://github.com/sagemath/sagecell/commit/035be7f050e550a9c66a75f3ad522e446ab2b1f2 Given that people still use old embedding, I don't think that there is any reasonable "deprecation period" that would work, we should just keep it forever for backward compatibility.

Rob Beezer

unread,
Mar 4, 2022, 7:42:03 PM3/4/22
to sage...@googlegroups.com
Dear Andrey,

Thanks for the fix. We did have our "own" jQuery at times, so who knows just
how I got confused.

Your instructions commit is dated June 12, 2016. "git blame" says the last time
I touched this code was committed June 13, 2016. Did not look too hard to see
if that is a coincidence or accident. I think it is cosmetic. ;-)

https://github.com/PreTeXtBook/pretext/commit/429861fd2297bb303c75ad89115ab6a87cd2ecad

We'll get this fixed up so "new" pages will be right.

Rob
> <https://groups.google.com/d/msgid/sage-cell/MTAwMDAzNy5iZWV6ZXI.1646411796%40quikprotect>.
>
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to sage-cell+...@googlegroups.com
> <mailto:sage-cell+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/33e375d4-72c3-44a2-9205-b1a1fac6ba85n%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-cell/33e375d4-72c3-44a2-9205-b1a1fac6ba85n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Andrey Novoseltsev

unread,
Mar 6, 2022, 9:09:06 PM3/6/22
to sage-cell
I tend to think that supporting "old" pages is important as well, although in practice old code may stop working because of incompatibilities with newer Sage. At the moment the new code is patched by Jason to restore not-so-right behaviour of silently initializing global jQuery and unless we remove this code it will be so indefinitely. Curiously enough, the other issue with changes led to a comment "The cell is created in an iFrame, btw, to work around the jquery version problem." So presumably in some cases it would be better not to initialize it externally...

Anyway - please test your pages to make sure that there are no other surprises!

Andrey

David Guichard

unread,
Mar 6, 2022, 9:10:19 PM3/6/22
to David Farmer, sage-cell
Ah, sorry, I thought they were there but not functioning.

-- David
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/alpine.LRH.2.21.2203041138020.17450%40li375-150.members.linode.com.
>

Rob Beezer

unread,
Mar 18, 2022, 12:16:12 AM3/18/22
to sage...@googlegroups.com
The fix is in:

https://github.com/PreTeXtBook/pretext/commit/ffc97db259f8cced75b6ccaf8c0f1394a4b03953

So new HTML builds should use a saner setup now. Thanks for keeping the old
setup alive. I've put out the need to rebuild on our announcement list, and if
I remember, the start of summer could be a good time for me to remind folks.

Rob
> <https://groups.google.com/d/msgid/sage-cell/33e375d4-72c3-44a2-9205-b1a1fac6ba85n%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/msgid/sage-cell/33e375d4-72c3-44a2-9205-b1a1fac6ba85n%40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to sage-cell+...@googlegroups.com
> <mailto:sage-cell+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cell/2729388e-3ea7-48ba-80b9-d31f9202372an%40googlegroups.com
> <https://groups.google.com/d/msgid/sage-cell/2729388e-3ea7-48ba-80b9-d31f9202372an%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages