Dear Andrew,
I understand what you are after here, though it took me a bit to remember
everything going on with "interactive".
What you propose is what I call "mixed content". Right now, a (JS)
"interactive" has a small predictable list of children, of our design (such as
"slate"). Your proposal introduces new children, perhaps more than just a
"script", to be duplicated (in the "head" I guess). In your example, I would
have put the "script" first. Could an author put it in-between two "slate"?
This is analogous to a "p" with a bunch of text nodes interspersed with a bunch
elements like "em" and "m".
And the punch-line: mixed-content is difficult to deal with. So any add-ins
like "script" need to go into some kind of container so that all the
"interactive" code does not need a reworking due to radically different
assumptions about its content.
<interactive ....>
<literal-html-for-head>
<script...>
new LinkedList(canvas1, [10,20]);
</script>
</literal-html-for-head>
<slate ..../>
<slate .../>
</interactive>
Perhaps more flexible, as yuou widsh, but perhaps more verbose that you wish.
"interactive" tries to be easy for those without JS skills, while giving power
authors flexibility to do the sort of things you are after here. And if we
heeded every objection to verbosity there would be no PreTeXt. ;-)
Bonus: maybe only need a single namespace declaration on the container?
I'll let Brad address the reporting to Runestone. We can, of course, support
that on the PreTeXt side.
Rob
On 3/5/24 15:38, Andrew Scholer wrote:
> I was thinking it makes sense to have the <script> element be independent of the
> <slate>.
>
> For this use case the location does not matter much. But there might be some JS
> interactive that wanted a small scriptlet, but did not need a <slate>.
>
> Andrew Scholer (he/him/his)
> Computer Science Instructor/Program Chair
> Chemeketa Community College
>
503.589.7649
>
computerscience.chemeketa.edu/people/andrew-scholer/
> <
http://computerscience.chemeketa.edu/people/andrew-scholer/>
>
>
> On Tue, Mar 5, 2024 at 3:24 PM 'Rob Beezer' via PreTeXt development
> <
prete...@googlegroups.com <mailto:
prete...@googlegroups.com>> wrote:
>
> Naive question at first blush. In your very first example, could the "script"
> be a child of the "slate" that is a canvas? (I'm not asking if it behaves,
> currently, just would the markup be more to your liking.)
>
> On 3/5/24 14:43, Andrew Scholer wrote:
> > Two questions about JS-based interactives.
> >
> > 1) Would it be reasonable to add a "body" to canvas slates within javascript
> > interactives
> >
> > Say I have an interactive based on mylib.js. mylib.js has many different
> > functions I might want to use, each taking arbitrary initialization data.
> I am
> > going to use this in many places in my text and want to easily express
> "use that
> > library to make a linked list with 10, 20" or "use that library to make a
> linked
> > list with 10, 20, 30". I don't want to have to make a separate js file
> for each
> > instance.
> >
> > Currently, this looks like what I would do:
> >
> > <interactive platform="javascript" source="code/mylib.js">
> > <slate surface="canvas" xml:id="canvas1"/>
> > <slate surface="html">
> > <script xmlns="
http://www.w3.org/1999/xhtml
> <
http://www.w3.org/1999/xhtml> <
http://www.w3.org/1999/xhtml
> (
https://docs.google.com/document/d/1X6Vx6Em67t8Vp4Vecnmc-7OblVewJJKDFIJUrvRAvdc/edit#heading=h.r0syp685x130 <
https://docs.google.com/document/d/1X6Vx6Em67t8Vp4Vecnmc-7OblVewJJKDFIJUrvRAvdc/edit#heading=h.r0syp685x130> <
https://docs.google.com/document/d/1X6Vx6Em67t8Vp4Vecnmc-7OblVewJJKDFIJUrvRAvdc/edit#heading=h.r0syp685x130 <
https://docs.google.com/document/d/1X6Vx6Em67t8Vp4Vecnmc-7OblVewJJKDFIJUrvRAvdc/edit#heading=h.r0syp685x130>>) Does anyone know more about that?
> > <
http://computerscience.chemeketa.edu/people/andrew-scholer/
> <mailto:
pretext-dev%2Bunsu...@googlegroups.com>
> > <mailto:
pretext-dev...@googlegroups.com
> <mailto:
pretext-dev%2Bunsu...@googlegroups.com>>.
> > To view this discussion on the web visit
> >
>
https://groups.google.com/d/msgid/pretext-dev/CACm44N_aiW_cWn7t-Tw3kDQUzsOgO_o5_8TxjqLLK0Jc%2BegfeQ%40mail.gmail.com <
https://groups.google.com/d/msgid/pretext-dev/CACm44N_aiW_cWn7t-Tw3kDQUzsOgO_o5_8TxjqLLK0Jc%2BegfeQ%40mail.gmail.com> <
https://groups.google.com/d/msgid/pretext-dev/CACm44N_aiW_cWn7t-Tw3kDQUzsOgO_o5_8TxjqLLK0Jc%2BegfeQ%40mail.gmail.com?utm_medium=email&utm_source=footer <
https://groups.google.com/d/msgid/pretext-dev/CACm44N_aiW_cWn7t-Tw3kDQUzsOgO_o5_8TxjqLLK0Jc%2BegfeQ%40mail.gmail.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%2Bunsu...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxMC5iZWV6ZXI.1709681046%40quikprotect <
https://groups.google.com/d/msgid/pretext-dev/MTAwMDAxMC5iZWV6ZXI.1709681046%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
>
https://groups.google.com/d/msgid/pretext-dev/CACm44N-Hn5wgkXFB12m0YD8xLUmiqF-qvRjYnhYNHsXPJYqjfQ%40mail.gmail.com <
https://groups.google.com/d/msgid/pretext-dev/CACm44N-Hn5wgkXFB12m0YD8xLUmiqF-qvRjYnhYNHsXPJYqjfQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.