RS assignment page is moving the closure of a certain span

59 views
Skip to first unread message

Alex Jordan

unread,
Sep 25, 2023, 5:13:24 PM9/25/23
to prete...@googlegroups.com
Here is ORCCA on Runestone, in particular look at checkpoint 1.1.2:
Just take a look at its static form; this is not about a live WeBWorK.

Now here is what we see for that in the assignments area:

Screenshot 2023-09-25 at 2.03.37 PM.png

It's all messed up after the first answer blank. The answer blank in question is an empty span with styling to make it shaded (or underlined, or boxed, as the publisher decides). In the assignment page, when I look at the page source, I see something good:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"/> be the age of a student,

But in the browser DOM (Firefox), I see:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"> be the age of a student, measured in <span class="fillin shade" role="img" aria-label="10-character blank" style="width: 4.545454545454546em;">.</span></span>

Notice how that span that makes that first answer blank does not self-close, and instead the browser gave it a closing span tag later. If I manually edit the DOM, that does fix this bad layout issue.

So what is going on here? Why does the page source correctly close this span, but when rendered in the assignments page, the closing of that span has been moved?

Brad Miller

unread,
Sep 25, 2023, 7:22:21 PM9/25/23
to prete...@googlegroups.com, Alex Jordan
Alex,

Stuff like this typically happens because the assignments page needs another .css or .js file.  I'm happy to add them to the list that we load for the assignment page, but I have no way of knowing what files need to be loaded.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting
On Sep 25, 2023 at 5:13 PM -0400, Alex Jordan <jordanc...@gmail.com>, wrote:
Here is ORCCA on Runestone, in particular look at checkpoint 1.1.2:
Just take a look at its static form; this is not about a live WeBWorK.

Now here is what we see for that in the assignments area:

<Screenshot 2023-09-25 at 2.03.37 PM.png>

It's all messed up after the first answer blank. The answer blank in question is an empty span with styling to make it shaded (or underlined, or boxed, as the publisher decides). In the assignment page, when I look at the page source, I see something good:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"/> be the age of a student,

But in the browser DOM (Firefox), I see:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"> be the age of a student, measured in <span class="fillin shade" role="img" aria-label="10-character blank" style="width: 4.545454545454546em;">.</span></span>

Notice how that span that makes that first answer blank does not self-close, and instead the browser gave it a closing span tag later. If I manually edit the DOM, that does fix this bad layout issue.

So what is going on here? Why does the page source correctly close this span, but when rendered in the assignments page, the closing of that span has been moved?

--
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/CA%2BR-jrepSOEEL87A9%2BQoU6%2BoEq31ujB5L%2BKLxHwmHk2YYJwXog%40mail.gmail.com.

Brad Miller

unread,
Sep 25, 2023, 7:27:05 PM9/25/23
to prete...@googlegroups.com
Alex, reading more closely... The assignment page is built from the htmlsrc entries in the database for each assignment, which is built from the runestone-manifest.xml file.  If the source there is missing the end span, that is a problem in generating the manifest.  We haven't seen that before, but could certainly be an issue....

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting
On Sep 25, 2023 at 5:13 PM -0400, Alex Jordan <jordanc...@gmail.com>, wrote:
Here is ORCCA on Runestone, in particular look at checkpoint 1.1.2:
Just take a look at its static form; this is not about a live WeBWorK.

Now here is what we see for that in the assignments area:

<Screenshot 2023-09-25 at 2.03.37 PM.png>

It's all messed up after the first answer blank. The answer blank in question is an empty span with styling to make it shaded (or underlined, or boxed, as the publisher decides). In the assignment page, when I look at the page source, I see something good:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"/> be the age of a student,

But in the browser DOM (Firefox), I see:

Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"> be the age of a student, measured in <span class="fillin shade" role="img" aria-label="10-character blank" style="width: 4.545454545454546em;">.</span></span>

Notice how that span that makes that first answer blank does not self-close, and instead the browser gave it a closing span tag later. If I manually edit the DOM, that does fix this bad layout issue.

So what is going on here? Why does the page source correctly close this span, but when rendered in the assignments page, the closing of that span has been moved?

Alex Jordan

unread,
Sep 25, 2023, 7:28:58 PM9/25/23
to Brad Miller, prete...@googlegroups.com
Did my description make sense though? The page's html source does not match the dom I see in the browser inspector, in a concerning way. To me it seems if anything, there is some js that is already present and doing something bad. Rather than some js or css missing.

Brad Miller

unread,
Sep 25, 2023, 7:56:08 PM9/25/23
to prete...@googlegroups.com
Alex,

I have no idea.  All I do is take the html out of the database and insert it into the page, without modification.  Have you tried this in other browsers?  What might be different about this question that the many other fill in the blank questions that are working fine?

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Andrew Scholer

unread,
Sep 25, 2023, 8:17:10 PM9/25/23
to prete...@googlegroups.com
Self closing span tags are not valid HTML. When HTML isn't valid, all bets are off for what is going to happen. It would not surprise me in the least if the same valid html got rendered differently in different situations. (i.e. served up as an independent document, vs inserted into a page, vs inserted into a page with a different structure).

Pretty sure whatever is generating that HTML needs to be generating an actual tag pair for the span element. 

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


Brad Miller

unread,
Sep 25, 2023, 8:26:06 PM9/25/23
to prete...@googlegroups.com
Also Alex `pretext_add_on.css` is not included in the assignments page.  

We need a more comprehensive set of test problems so that I can include the css that is really needed.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Alex Jordan

unread,
Sep 25, 2023, 8:32:02 PM9/25/23
to prete...@googlegroups.com
I think Andrew must have it. I'll track down the source of a self closing span. 

Steven Clontz

unread,
Sep 25, 2023, 8:43:17 PM9/25/23
to prete...@googlegroups.com
I think Andrew's called it. I think self closing tags are valid in xhtml (as it's XML) but not HTML5.

Rob Beezer

unread,
Sep 25, 2023, 9:17:45 PM9/25/23
to prete...@googlegroups.com
http://xahlee.info/js/html5_non-closing_tag.html
>>> *Bradley Miller, PhD*
>>> Professor Emeritus Computer Science
>>> Luther College
>>> Founder, Runestone Academy LTD <https://runestone.academy>
>>> Blog: A Reputable Journal <https://www.reputablejournal.com>
>>> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
>>> On Sep 25, 2023 at 7:26 PM -0400, Brad Miller <br...@runestone.academy>,
>>> wrote:
>>>
>>> Alex, reading more closely... The assignment page is built from the
>>> htmlsrc entries in the database for each assignment, which is built from
>>> the runestone-manifest.xml file. If the source there is missing the end
>>> span, that is a problem in generating the manifest. We haven't seen that
>>> before, but could certainly be an issue....
>>>
>>> *Bradley Miller, PhD*
>>> Professor Emeritus Computer Science
>>> Luther College
>>> Founder, Runestone Academy LTD <https://runestone.academy>
>>> Blog: A Reputable Journal <https://www.reputablejournal.com>
>>> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
>>> <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jrepSOEEL87A9%2BQoU6%2BoEq31ujB5L%2BKLxHwmHk2YYJwXog%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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/pretext-dev/2794addd-9420-42f6-ab22-cba196370b2e%40Spark
>>> <https://groups.google.com/d/msgid/pretext-dev/2794addd-9420-42f6-ab22-cba196370b2e%40Spark?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/CACm44N9AxF-Euxtc3RcQ8FsM_wL0E4JwYp3k39a5z%2BzdToQHxA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/pretext-dev/CACm44N9AxF-Euxtc3RcQ8FsM_wL0E4JwYp3k39a5z%2BzdToQHxA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

Rob Beezer

unread,
Sep 25, 2023, 10:13:11 PM9/25/23
to prete...@googlegroups.com
Would placing a single space character as content of the "fillin" span resolve the problem?

Alex Jordan

unread,
Sep 25, 2023, 11:30:36 PM9/25/23
to prete...@googlegroups.com
It is unfortunate that pretext-html.xsl has:
xsl:output method="html"

but still things like this empty span come out as self-closing, instead of using a closing tag. It's not like it's coded that way in the XSL.

If this is just how our XSLT processor works, I think there's nothing to do except give the empty span some content. Rob suggests a space. The only less obtrusive thing I can think of would be a legal empty element and <wbr/> is the only one that seems reasonable.

We produce other empty spans too, not just fillin. I could look for all of them and make this change in one PR. Is a space the way to go?

Brad Miller

unread,
Sep 26, 2023, 6:15:53 AM9/26/23
to prete...@googlegroups.com
I will ask my question again….   What makes this particular webwork fillin different from the multitude of webwork fillins that are working just fine on the assignments page?  

I have tracked down quite a few problems like this for others over the past months and most of the time it comes down to:
  1. Needing a wrapper with some class on it.  (I think those are alll found)
  2. Oh, I guess we do need to include xxx.css on the assignment page for this particular problem.

Brad

Bradley Miller, PhD

Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Brad Miller

unread,
Sep 26, 2023, 7:49:59 AM9/26/23
to prete...@googlegroups.com
And I will jump on the empty span bandwagon now.... How strange that "in context" the browser (chrome) adds the close span in the correct place, but on the assignment page the browser tries to put the text following the empty span inside the span...  This behavior mimics a few different examples on Stack Overflow regarding empty spans.

I can confirm that we have all the right wrappers, and I forgot that I added pretext_add_on.css last week, so that is there for styling.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Rob Beezer

unread,
Sep 26, 2023, 11:15:52 AM9/26/23
to prete...@googlegroups.com
> If this is just how our XSLT processor works

Unfortunate or not, the way our XSLT processor "serializes" the "result tree" is
mostly beyond our control, with few opportunities to influence its behavior. I
believe this is mostly a good thing.

Another mystery is what it creates at the tip-top of an HTML page. In the XSL
you will see:

doctype-system="about:legacy-compat"

which is equally odd and important. Namespaces play a role as well.

Anyway, an experiment for Brad or somebody else who knows their way around teh
assignment builder.

Copy the first few lines of an "in context" page produced by PreText into the
first few lines of the assignment page and see if that changes behavior.

Rob

On 9/26/23 04:49, Brad Miller wrote:
> And I will jump on the empty span bandwagon now.... How strange that "in
> context" the browser (chrome) adds the close span in the correct place, but on
> the assignment page the browser tries to put the text following the empty span
> inside the span...  This behavior mimics a few different examples on Stack
> Overflow regarding empty spans.
>
> I can confirm that we have all the right wrappers, and I forgot that I added
> pretext_add_on.css last week, so that is there for styling.
>
> Brad
>
> *Bradley Miller, PhD*
> Professor Emeritus Computer Science
> Luther College
> Founder, Runestone Academy LTD <https://runestone.academy>
> Blog: A Reputable Journal <https://www.reputablejournal.com>
> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
> On Sep 26, 2023 at 6:15 AM -0400, Brad Miller <br...@runestone.academy>, wrote:
>> I will ask my question again….   What makes this particular webwork fillin
>> different from the multitude of webwork fillins that are working just fine on
>> the assignments page?
>>
>> I have tracked down quite a few problems like this for others over the past
>> months and most of the time it comes down to:
>>
>> 1. Needing a wrapper with some class on it.  (I think those are alll found)
>> 2. Oh, I guess we do need to include xxx.css on the assignment page for this
>> particular problem.
>>
>>
>> Brad
>>
>> *Bradley Miller, PhD*
>> Professor Emeritus Computer Science
>> Luther College
>> Founder, Runestone Academy LTD <https://runestone.academy>
>> Blog: A Reputable Journal <https://www.reputablejournal.com>
>> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
>> On Sep 26, 2023 at 00:30 -0300, Alex Jordan <jordanc...@gmail.com>, wrote:
>>> It is unfortunate that pretext-html.xsl has:
>>> xsl:output method="html"
>>>
>>> but still things like this empty span come out as self-closing, instead of
>>> using a closing tag. It's not like it's coded that way in the XSL.
>>>
>>> If this is just how our XSLT processor works, I think there's nothing to do
>>> except give the empty span some content. Rob suggests a space. The only less
>>> obtrusive thing I can think of would be a legal empty element and <wbr/> is
>>> the only one that seems reasonable.
>>>
>>> We produce other empty spans too, not just fillin. I could look for all of
>>> them and make this change in one PR. Is a space the way to go?
>>>
>>> On Mon, Sep 25, 2023 at 7:13 PM Rob Beezer <bee...@privacyport.com
>>> <mailto:bee...@privacyport.com>> wrote:
>>>
>>> Would placing a single space character as content of the "fillin" span
>>> resolve the problem?
>>>
>>> On September 25, 2023 6:17:36 PM PDT, Rob Beezer <bee...@privacyport.com
>>> <mailto:bee...@privacyport.com>> wrote:
>>> >http://xahlee.info/js/html5_non-closing_tag.html
>>> <http://xahlee.info/js/html5_non-closing_tag.html>
>>> >
>>> >On September 25, 2023 5:43:04 PM PDT, Steven Clontz
>>> <steven...@gmail.com <mailto:steven...@gmail.com>> wrote:
>>> >>I think Andrew's called it. I think self closing tags are valid in xhtml
>>> >>(as it's XML) but not HTML5.
>>> >>
>>> >>On Mon, Sep 25, 2023, 7:17 PM Andrew Scholer
>>> <andrew....@chemeketa.edu <mailto:andrew....@chemeketa.edu>>
>>> >>wrote:
>>> >>
>>> >>> Self closing span tags are not valid HTML. When HTML isn't valid, all
>>> bets
>>> >>> are off for what is going to happen. It would not surprise me in the
>>> least
>>> >>> if the same valid html got rendered differently in different situations.
>>> >>> (i.e. served up as an independent document, vs inserted into a page, vs
>>> >>> inserted into a page with a different structure).
>>> >>>
>>> >>> Pretty sure whatever is generating that HTML needs to be generating an
>>> >>> actual tag pair for the span element.
>>> >>>
>>> >>> 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/>
>>> <https://fantastical.app/bonelake-Gj2i/meet-with-brad>>
>>> >>>> On Sep 25, 2023 at 5:13 PM -0400, Alex Jordan
>>> <jordanc...@gmail.com <mailto:jordanc...@gmail.com>>,
>>> >>>> wrote:
>>> >>>>
>>> >>>> Here is ORCCA on Runestone, in particular look at checkpoint 1.1.2:
>>> >>>>
>>> >>>>
>>> https://runestone.academy/ns/books/published/portlandcommunitycollege_orcca_fall23/section-variables-and-evaluating-expressions.html <https://runestone.academy/ns/books/published/portlandcommunitycollege_orcca_fall23/section-variables-and-evaluating-expressions.html>
>>> <mailto:pretext-dev%2Bunsu...@googlegroups.com>.
>>> <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jrepSOEEL87A9%2BQoU6%2BoEq31ujB5L%2BKLxHwmHk2YYJwXog%40mail.gmail.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jrepSOEEL87A9%2BQoU6%2BoEq31ujB5L%2BKLxHwmHk2YYJwXog%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>.
>>> <https://groups.google.com/d/msgid/pretext-dev/2794addd-9420-42f6-ab22-cba196370b2e%40Spark?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/pretext-dev/2794addd-9420-42f6-ab22-cba196370b2e%40Spark?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>.
>>> <https://groups.google.com/d/msgid/pretext-dev/CACm44N9AxF-Euxtc3RcQ8FsM_wL0E4JwYp3k39a5z%2BzdToQHxA%40mail.gmail.com?utm_medium=email&utm_source=footer <https://groups.google.com/d/msgid/pretext-dev/CACm44N9AxF-Euxtc3RcQ8FsM_wL0E4JwYp3k39a5z%2BzdToQHxA%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/MTAwMDAwOS5iZWV6ZXI.1695694390%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDAwOS5iZWV6ZXI.1695694390%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/CA%2BR-jrcLDeXXcBpWWWMZd_Tp17qcfqLTyfJueFTXVV0hX3jmFA%40mail.gmail.com <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jrcLDeXXcBpWWWMZd_Tp17qcfqLTyfJueFTXVV0hX3jmFA%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...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/d4007cea-584f-49e5-a6ee-e4ea2f616e07%40Spark <https://groups.google.com/d/msgid/pretext-dev/d4007cea-584f-49e5-a6ee-e4ea2f616e07%40Spark?utm_medium=email&utm_source=footer>.

Rob Beezer

unread,
Sep 26, 2023, 11:19:42 AM9/26/23
to prete...@googlegroups.com
On 9/25/23 20:30, Alex Jordan wrote:
> We produce other empty spans too, not just fillin. I could look for all of them
> and make this change in one PR. Is a space the way to go?

At the moment this problem is confined to the Runestone assignment builder page.
The PreTeXt templates are designed to produce identical HTML in-context and
in-manifest. So I doubt that different HTML is going *into* the database (but
would appreciate evidence to the contrary).

So there is no reason just yet to change *anything* on the PreTeXt side until we
understand the Runestone side or we have evidence of a problem in a
non-Runestone context.

Rob

Alex Jordan

unread,
Sep 26, 2023, 12:20:41 PM9/26/23
to prete...@googlegroups.com
> What makes this particular webwork fillin different from the multitude of webwork fillins that are working just fine on the assignments page? 

I don't see any other fillins working just fine on that page. They all have this issue. It is harder to see visually when the fillin does not have text following it though, which is probably common. On the particular page I am looking at, many other fillins on that page are followed by a period, and you can see that period is not where it should be:

Screenshot 2023-09-26 at 9.16.32 AM.png

I have more information now, following up with a reply to Rob.






--
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.

Alex Jordan

unread,
Sep 26, 2023, 12:36:05 PM9/26/23
to prete...@googlegroups.com
Here is some page source for an exercise in the book, as hosted on Runestone:
Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"></span> be
It has a closing span tag. All is well. The html serializer is doing a good thing.

Here is page source for the same thing in the Runestone assignments page.
Let <span class="fillin shade" role="img" aria-label="3-character blank" style="width: 1.363636363636364em;"/> be
Not OK. The span self-closes. The browser is reading it as an open tag only. In the DOM, it closes the span later, when the enclosing div.para ends.

If I understand right, this line in pretext-runestone.xsl creates the manifest file with this differently-seriealized content:
<exsl:document href="runestone-manifest.xml" method="xml" indent="yes" encoding="UTF-8">

So we have the empty span being serialized as XML, not HTML, and it gets written with a self-closing tag instead of a separate closing tag.


On Tue, Sep 26, 2023 at 8:19 AM Rob Beezer <bee...@privacyport.com> wrote:
--
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,
Sep 26, 2023, 12:45:58 PM9/26/23
to prete...@googlegroups.com
OK, that sounds plausible. Very good.

The manifest has a non-HTML structure to it, with ad-hoc tags like "htmlsrc",
thus the decision to use the "xml" output method. That can change.

Two possible (speculative) outcomes with method="html":

1. The page is a mess for humans to read (it may be already!) and maybe some
stray namespace *declarations* (not prefixes) on the made-up tags. maybe the
"pi" prefix would be useful? I can test easily.

2. We switch all the non-standard tags to standard ones

<div data-runestone="htmlsrc">

A bit of tedium for Brad and for me.


It would be good to know what sort of tool Brad is using to read the manifest as
it migrates to the database, before diving into something.

Rob

On 9/26/23 09:35, Alex Jordan wrote:
> Here is some page source for an exercise in the book, as hosted on Runestone:
>
> Let <span class="fillin shade" role="img" aria-label="3-character blank"
> style="width: 1.363636363636364em;"></span>be
>
> It has a closing span tag. All is well. The html serializer is doing a good thing.
>
> Here is page source for the same thing in the Runestone assignments page.
>
> Let <span class="fillin shade" role="img" aria-label="3-character blank"
> style="width: 1.363636363636364em;"/>be
>
> Not OK. The span self-closes. The browser is reading it as an open tag only. In
> the DOM, it closes the span later, when the enclosing div.para ends.
>
> If I understand right, this line in pretext-runestone.xsl creates the manifest
> file with this differently-seriealized content:
> <exsl:documenthref="runestone-manifest.xml"method="xml"indent="yes"encoding="UTF-8">
>
> So we have the empty span being serialized as XML, not HTML, and it gets written
> with a self-closing tag instead of a separate closing tag.
>
>
> On Tue, Sep 26, 2023 at 8:19 AM Rob Beezer <bee...@privacyport.com
> <mailto:bee...@privacyport.com>> wrote:
>
> On 9/25/23 20:30, Alex Jordan wrote:
> > We produce other empty spans too, not just fillin. I could look for all
> of them
> > and make this change in one PR. Is a space the way to go?
>
> At the moment this problem is confined to the Runestone assignment builder
> page.
>   The PreTeXt templates are designed to produce identical HTML in-context and
> in-manifest.  So I doubt that different HTML is going *into* the database (but
> would appreciate evidence to the contrary).
>
> So there is no reason just yet to change *anything* on the PreTeXt side
> until we
> understand the Runestone side or we have evidence of a problem in a
> non-Runestone context.
>
> Rob
>
> --
> 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/MTAwMDA0Mi5iZWV6ZXI.1695741581%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDA0Mi5iZWV6ZXI.1695741581%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/CA%2BR-jreAnQk-B_7XyFe5yDfmiiCx-Sk4WJLYyMrsf85OBTTj0A%40mail.gmail.com <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jreAnQk-B_7XyFe5yDfmiiCx-Sk4WJLYyMrsf85OBTTj0A%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Steven Clontz

unread,
Sep 26, 2023, 12:46:29 PM9/26/23
to prete...@googlegroups.com
Perhaps e.g. https://github.com/RunestoneInteractive/rs/blob/10bfd6eb5a3cbb6d6b5e1e5880f004f8691bcf29/components/rsptx/build_tools/core.py#L607 needs to be wrapped with a conversion from XML to HTML. 

Maybe something of the flavor...  lxml.etree.tostring(lxml.html.fromstring(lxml.etree.tostring(element)))


Brad Miller

unread,
Sep 26, 2023, 3:44:33 PM9/26/23
to prete...@googlegroups.com
Here is what I can report very quickly.
  1. The runestone-manifest.xml file has the self closing span.
  2. The database has the self closing span.
  3. If I do a show source on the doAssignment page the self closing span is in the page source.
  4. But... when you inspect the source to see the DOM then the spans are closed with tags incorrectly.

@Alex -- The Active Calculus book has many many working examples of fillins.

@Rob The first few lines of the html for the in-context page look like this:
<html lang="en-US" dir="ltr">
<head xmlns:og="http://ogp.me/ns#" xmlns:book="https://ogp.me/ns/book#\
">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

I can experiment, but probably not today.

Brad

Bradley Miller, PhD

Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Alex Jordan

unread,
Sep 26, 2023, 3:55:21 PM9/26/23
to prete...@googlegroups.com
> @Alex -- The Active Calculus book has many many working examples of fillins.

They all have the same issue, as far as I can see from their HTML source. But this is a subtle thing I mentioned before: you cannot *see* the issue by looking at the rendered HTML, because (in every example I looked at) there happens to be no text following the fillin until after you exit the ambient div. So it happens to look fine. And that's normal for the OPL exercises that AC uses, which tend to have an answer blank and that's the end of that line/paragraph.

I looked harder and here in AC you see the same thing happening:

Screenshot 2023-09-26 at 12.51.15 PM.png

that "dx" should follow the fillin, not overlap it. This is in the 5.5b Preview assignment in franciscan_mth162_F23.

Alex Jordan

unread,
Sep 26, 2023, 3:57:11 PM9/26/23
to prete...@googlegroups.com
Copy-paste got fouled, here's that example:

Screenshot 2023-09-26 at 12.51.15 PM.png

Rob Beezer

unread,
Sep 26, 2023, 4:03:17 PM9/26/23
to prete...@googlegroups.com
> but probably not today.

Understood. No rush on my end.

Try this slimmed down version with (irrelevant?) pieces removed.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8">

Note that the "meta" element is not closed. ;-)

Rob

On 9/26/23 12:44, Brad Miller wrote:
> Here is what I can report very quickly.
>
> 1. The runestone-manifest.xml file has the self closing span.
> 2. The database has the self closing span.
> 3. If I do a show source on the doAssignment page the self closing span is in
> the page source.
> 4. But... when you inspect the source to see the DOM then the spans are closed
> with tags incorrectly.
>
>
> @Alex -- The Active Calculus book has many many working examples of fillins.
>
> @Rob The first few lines of the html for the in-context page look like this:
> <html lang="en-US" dir="ltr">
> <head xmlns:og="http://ogp.me/ns#" xmlns:book="https://ogp.me/ns/book#\
> ">
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>
> I can experiment, but probably not today.
>
> Brad
>
> *Bradley Miller, PhD*
> Professor Emeritus Computer Science
> Luther College
> Founder, Runestone Academy LTD <https://runestone.academy>
> Blog: A Reputable Journal <https://www.reputablejournal.com>
> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
> On Sep 26, 2023 at 12:46 PM -0400, Steven Clontz <steven...@gmail.com>, wrote:
>> Perhaps e.g.
>> https://github.com/RunestoneInteractive/rs/blob/10bfd6eb5a3cbb6d6b5e1e5880f004f8691bcf29/components/rsptx/build_tools/core.py#L607 <https://github.com/RunestoneInteractive/rs/blob/10bfd6eb5a3cbb6d6b5e1e5880f004f8691bcf29/components/rsptx/build_tools/core.py#L607> needs to be wrapped with a conversion from XML to HTML.
>>
>> Maybe something of the flavor...
>> lxml.etree.tostring(lxml.html.fromstring(lxml.etree.tostring(element)))
>>
>>
>> Steven Clontz
>> https://clontz.org <https://clontz.org> - steven...@gmail.com
>> <mailto:steven...@gmail.com>
>> <mailto:pretext-dev%2Bunsu...@googlegroups.com>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pretext-dev/MTAwMDA0Mi5iZWV6ZXI.1695741581%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDA0Mi5iZWV6ZXI.1695741581%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/CA%2BR-jreAnQk-B_7XyFe5yDfmiiCx-Sk4WJLYyMrsf85OBTTj0A%40mail.gmail.com <https://groups.google.com/d/msgid/pretext-dev/CA%2BR-jreAnQk-B_7XyFe5yDfmiiCx-Sk4WJLYyMrsf85OBTTj0A%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...@googlegroups.com>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pretext-dev/CAOWT6Tg5Hj%2BPgrRfidVU-fSQBTF0KgGZU3cm86cv1QvRUdebGw%40mail.gmail.com <https://groups.google.com/d/msgid/pretext-dev/CAOWT6Tg5Hj%2BPgrRfidVU-fSQBTF0KgGZU3cm86cv1QvRUdebGw%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...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-dev/67346651-4862-4251-b280-9618bb3492b9%40Spark <https://groups.google.com/d/msgid/pretext-dev/67346651-4862-4251-b280-9618bb3492b9%40Spark?utm_medium=email&utm_source=footer>.

Andrew Scholer

unread,
Sep 26, 2023, 4:06:10 PM9/26/23
to prete...@googlegroups.com
The DOM view shows you what the browser did to "fix" the source it was given. That is why items 1-3 for Brad were consistent and the DOM view showed the closing tags - those tags were the browsers best guess as to what to do with the invalid HTML.

Sounds like there may be a more general issue with the fact that invalid HTML reaches the database. By the time it is in the db it really should be valid.

I think Steven has the right path. Either an extra pass to turn XML into HTML, or some other processing step in manifest_data_to_db can be done to change select self closing tags into tag pairs. If necessary by inserting an empty comment as the content in those elements.

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

Steven Clontz

unread,
Sep 26, 2023, 4:09:01 PM9/26/23
to prete...@googlegroups.com
Note that if the invalid HTML is being sent in a server response, you can see it with "View Source" but not in "Inspect" for the reason Andrew suggests.

Rob Beezer

unread,
Sep 26, 2023, 4:11:55 PM9/26/23
to prete...@googlegroups.com
On 9/26/23 13:05, Andrew Scholer wrote:
> I think Steven has the right path. Either an extra pass to turn XML into HTML,
> or some other processing step in *manifest_data_to_db* can be done to change
> select self closing tags into tag pairs. If necessary by inserting an empty
> comment as the content in those elements.

Not that I'm looking for trouble, and I love the idea that Runestone fixes this
by digesting the manifest with some massaging, but shouldn't the "htmlsrc"
element of the manifest really, really, truly, hold legitimate HTML?

Rob

Steven Clontz

unread,
Sep 26, 2023, 6:16:53 PM9/26/23
to prete...@googlegroups.com
>  shouldn't the "htmlsrc" element of the manifest really, really, truly, hold legitimate HTML?

Maybe. If so, then there's the pattern used for e.g. QTI XML files used for LMS exercise banks: when putting HTML into your XML data structure, first escape it so the HTML is contained with a single text node, so it can be used literally on the other side. Here's an example of what that looks like (as produced by https://teambasedinquirylearning.github.io/linear-algebra/2023/exercises/#/export for Moodle):

      <question type="essay">
        <name> <!-- Name for the question -->
          <text>LE3 ver. 100</text>
        </name>
        <questiontext format="html"> <!-- question text-->
          <text>&lt;div class&#x3D;&quot;stx&quot;&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-intro&quot;&gt;&lt;p&gt; Consider each of the following systems of linear equations or vector equations. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-intro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;\begin{matrix} 2 \, x_{1} &amp;amp; - &amp;amp; 6 \, x_{2} &amp;amp; - &amp;amp; 3 \, x_{3} &amp;amp; &#x3D; &amp;amp; 0 \\ -x_{1} &amp;amp; + &amp;amp; 3 \, x_{2} &amp;amp; + &amp;amp; 2 \, x_{3} &amp;amp; &#x3D; &amp;amp; -2 \\ 3 \, x_{1} &amp;amp; - &amp;amp; 9 \, x_{2} &amp;amp; + &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -3 \\ 11 \, x_{1} &amp;amp; - &amp;amp; 33 \, x_{2} &amp;amp; + &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -13 \\ \end{matrix}&quot;&gt;\[\begin{matrix} 2 \, x_{1} &amp;amp; - &amp;amp; 6 \, x_{2} &amp;amp; - &amp;amp; 3 \, x_{3} &amp;amp; &#x3D; &amp;amp; 0 \\ -x_{1} &amp;amp; + &amp;amp; 3 \, x_{2} &amp;amp; + &amp;amp; 2 \, x_{3} &amp;amp; &#x3D; &amp;amp; -2 \\ 3 \, x_{1} &amp;amp; - &amp;amp; 9 \, x_{2} &amp;amp; + &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -3 \\ 11 \, x_{1} &amp;amp; - &amp;amp; 33 \, x_{2} &amp;amp; + &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -13 \\ \end{matrix}\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain and demonstrate how to find a simpler linear system that has the same solution set. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain whether this solution set has no solutions, one solution, or infinitely-many solutions. If the set is finite, describe it using set notation. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-intro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;x_{1} \left[\begin{array}{c} 1 \\ 0 \\ 2 \\ 7 \end{array}\right] + x_{2} \left[\begin{array}{c} 2 \\ 0 \\ 4 \\ 14 \end{array}\right] + x_{3} \left[\begin{array}{c} 2 \\ 1 \\ 3 \\ 14 \end{array}\right] &#x3D; \left[\begin{array}{c} -4 \\ -1 \\ -7 \\ -28 \end{array}\right]&quot;&gt;\[x_{1} \left[\begin{array}{c} 1 \\ 0 \\ 2 \\ 7 \end{array}\right] + x_{2} \left[\begin{array}{c} 2 \\ 0 \\ 4 \\ 14 \end{array}\right] + x_{3} \left[\begin{array}{c} 2 \\ 1 \\ 3 \\ 14 \end{array}\right] &#x3D; \left[\begin{array}{c} -4 \\ -1 \\ -7 \\ -28 \end{array}\right]\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain and demonstrate how to find a simpler linear system that has the same solution set. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain whether this solution set has no solutions, one solution, or infinitely-many solutions. If the set is finite, describe it using set notation. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-intro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;x_{1} \left[\begin{array}{c} 0 \\ -1 \\ 0 \\ -2 \end{array}\right] + x_{2} \left[\begin{array}{c} 1 \\ 1 \\ 0 \\ 5 \end{array}\right] + x_{3} \left[\begin{array}{c} 4 \\ 1 \\ 1 \\ 16 \end{array}\right] &#x3D; \left[\begin{array}{c} -2 \\ 3 \\ -1 \\ -2 \end{array}\right]&quot;&gt;\[x_{1} \left[\begin{array}{c} 0 \\ -1 \\ 0 \\ -2 \end{array}\right] + x_{2} \left[\begin{array}{c} 1 \\ 1 \\ 0 \\ 5 \end{array}\right] + x_{3} \left[\begin{array}{c} 4 \\ 1 \\ 1 \\ 16 \end{array}\right] &#x3D; \left[\begin{array}{c} -2 \\ 3 \\ -1 \\ -2 \end{array}\right]\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain and demonstrate how to find a simpler linear system that has the same solution set. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;
&lt;div class&#x3D;&quot;stx-content&quot;&gt;&lt;p&gt; Explain whether this solution set has no solutions, one solution, or infinitely-many solutions. If the set is finite, describe it using set notation. &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;

&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;div&gt;</text>
        </questiontext>
        <generalfeedback format="html"> <!-- solution text-->
          <text>&lt;div class&#x3D;&quot;stx&quot;&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;\begin{matrix} x_{1} &amp;amp; - &amp;amp; 3 \, x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}&quot;&gt;\[\begin{matrix} x_{1} &amp;amp; - &amp;amp; 3 \, x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt; The solution set has no solutions.  The solution set is &lt;span class&#x3D;&quot;math inline-math&quot; data-latex&#x3D;&quot;\emptyset&quot;&gt;\(\emptyset\)&lt;&#x2F;span&gt;.  &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;\begin{matrix} x_{1} &amp;amp; + &amp;amp; 2 \, x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; -2 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}&quot;&gt;\[\begin{matrix} x_{1} &amp;amp; + &amp;amp; 2 \, x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; -2 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt; The solution set has infinitely-many solutions.  &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;ol&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt;&lt;span class&#x3D;&quot;math display-math&quot; data-latex&#x3D;&quot;\begin{matrix} x_{1} &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; -2 \\ &amp;amp; &amp;amp; x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; 2 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}&quot;&gt;\[\begin{matrix} x_{1} &amp;amp; &amp;amp; &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; -2 \\ &amp;amp; &amp;amp; x_{2} &amp;amp; &amp;amp; &amp;amp; &#x3D; &amp;amp; 2 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; x_{3} &amp;amp; &#x3D; &amp;amp; -1 \\ &amp;amp; &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; &#x3D; &amp;amp; 0 \\ \end{matrix}\]&lt;&#x2F;span&gt;&lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;li&gt;&lt;div class&#x3D;&quot;stx-knowl&quot;&gt;

&lt;div class&#x3D;&quot;stx-outtro&quot;&gt;&lt;p&gt; The solution set has one solution.  The solution set is &lt;span class&#x3D;&quot;math inline-math&quot; data-latex&#x3D;&quot;\left\{ \left[\begin{array}{c} -2 \\ 2 \\ -1 \end{array}\right] \right\}&quot;&gt;\(\left\{ \left[\begin{array}{c} -2 \\ 2 \\ -1 \end{array}\right] \right\}\)&lt;&#x2F;span&gt;.  &lt;&#x2F;p&gt;&lt;&#x2F;div&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;&#x2F;div&gt;&lt;&#x2F;div&gt;</text>
        </generalfeedback>
        <defaultgrade>1.0000000</defaultgrade>
        <penalty>0.3333333</penalty>
        <hidden>0</hidden>
        <idnumber></idnumber>
        <responseformat>editor</responseformat>
        <responserequired>1</responserequired>
        <responsefieldlines>20</responsefieldlines>
        <minwordlimit></minwordlimit>
        <maxwordlimit></maxwordlimit>
        <attachments>1</attachments>
        <attachmentsrequired>0</attachmentsrequired>
        <maxbytes>0</maxbytes>
        <filetypeslist></filetypeslist>
        <graderinfo format="html">
          <text></text>
        </graderinfo>
        <responsetemplate format="html">
          <text></text>
        </responsetemplate>
      </question>
--
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,
Sep 26, 2023, 7:39:04 PM9/26/23
to prete...@googlegroups.com
Aah, yes, and we already have that. mode="serialize" in -common. Originally
for putting HTML into Jupyter notebooks as text (further sanitized for JSON).

Expanded from https://stackoverflow.com/a/15783514

I'll need to see if the HTML can be captured in a variable before being output
as XML (so still HTML), then hit with this template for transmission to RS.

On 9/26/23 15:16, Steven Clontz wrote:
> > shouldn't the "htmlsrc" element of the manifest really, really, truly, hold
> legitimate HTML?
>
> Maybe. If so, then there's the pattern used for e.g. QTI XML files used for LMS
> exercise banks: when putting HTML into your XML data structure, first escape it
> so the HTML is contained with a single text node, so it can be used literally on
> the other side. Here's an example of what that looks like (as produced by
> https://teambasedinquirylearning.github.io/linear-algebra/2023/exercises/#/export <https://teambasedinquirylearning.github.io/linear-algebra/2023/exercises/#/export> for Moodle):
> <mailto:steven...@gmail.com>
>
>
> On Tue, Sep 26, 2023 at 3:11 PM Rob Beezer <bee...@privacyport.com
> <mailto:bee...@privacyport.com>> wrote:
>
> On 9/26/23 13:05, Andrew Scholer wrote:
> > I think Steven has the right path. Either an extra pass to turn XML into
> HTML,
> > or some other processing step in *manifest_data_to_db* can be done to change
> > select self closing tags into tag pairs. If necessary by inserting an empty
> > comment as the content in those elements.
>
> Not that I'm looking for trouble, and I love the idea that Runestone fixes this
> by digesting the manifest with some massaging, but shouldn't the "htmlsrc"
> element of the manifest really, really, truly, hold legitimate HTML?
>
> Rob
>
> --
> 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/MTAwMDA0Ny5iZWV6ZXI.1695759114%40quikprotect <https://groups.google.com/d/msgid/pretext-dev/MTAwMDA0Ny5iZWV6ZXI.1695759114%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/CAOWT6TiF7uReo5tk%3DrfxjchAXSDB4wkZG4LDez2gLfWwyLinBg%40mail.gmail.com <https://groups.google.com/d/msgid/pretext-dev/CAOWT6TiF7uReo5tk%3DrfxjchAXSDB4wkZG4LDez2gLfWwyLinBg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Brad Miller

unread,
Sep 26, 2023, 8:46:15 PM9/26/23
to prete...@googlegroups.com, Rob Beezer
Ugh,

For all this time I have been able to insert the htmlsrc value as a "safe" string in assignments and grading....  Escaping everything, as in steven's example would be a big change, heaven only knows breaking what.  But also producing invalid html is equally problematic.

I have always been able to assume that the value of htmlsrc is, in fact, valid html.  Why not just produce valid html?  Its not that many more characters to add a </span> rather than making it self closing is it?  HTML5 is the accepted standard, for web programming.  One might wish for XHTML, but I think that ship sailed years ago.  I think that making the output for html and runestone be XML and hoping or assuming that things further down the tool chain will always understand that distinction is just asking for more trouble.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting
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/MTAwMDA0MC5iZWV6ZXI.1695771541%40quikprotect.

Brad Miller

unread,
Sep 27, 2023, 8:50:44 AM9/27/23
to prete...@googlegroups.com, Rob Beezer
Sorry, that was more whiney/ranty than it should have been.  

I do think that what goes into the DB should be valid html.  Those fragments are used in way too many places and inserted into pages for previewing, grading, assignments, etc...  We don't want to have to fix them up when we want to render them.  Converting them at the time we process the manifest is an option if we can do it reliably.   So, this morning I tried Steven's idea.

from lxml import etree as ET
from lxml import html
testfrag = "<div><span id='foo'/>foo bar</div>"
ET.tostring(html.fromstring(testfrag))

Unfortunately this leaves the span as self closing...

I think the best solution is to create valid html from the start, fixing things downstream just feels brittle and error prone (as we are seeing).

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting
On Sep 26, 2023 at 7:39 PM -0400, Rob Beezer <bee...@privacyport.com>, wrote:
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/MTAwMDA0MC5iZWV6ZXI.1695771541%40quikprotect.

Brad Miller

unread,
Sep 27, 2023, 9:10:55 AM9/27/23
to prete...@googlegroups.com, Rob Beezer
There is a way with xml to get it to add the close span tag, but it involves walking all of the nodes in the fragment.  If they have an empty @text then set that text to an empty string.  Then when you convert it, it will have a separate close span tag in the right place.   Feels like a hack that could cause further problems though.

Brad

Bradley Miller, PhD
Professor Emeritus Computer Science
Luther College
Founder, Runestone Academy LTD
Blog: A Reputable Journal
Schedule a Meeting

Steven Clontz

unread,
Sep 27, 2023, 9:32:31 AM9/27/23
to prete...@googlegroups.com, Rob Beezer
I feel like I tackled this a couple years back for CheckIt, though it's moot these days for that project. Digging through the history I find this:


So maybe this (cludgy) line works? In particular, use `html.tostring` rather than `etree.tostring` to output HTML rather than XML?

lxml.html.tostring(lxml.html.fromstring(lxml.etree.tostring(xml_element_representing_html_fragement)))

Rob Beezer

unread,
Sep 27, 2023, 11:19:11 AM9/27/23
to prete...@googlegroups.com
> Ugh.

Don't panic! You should be relaxing around the campfire.

> Escaping everything

We aren't going there. We make a **text** version of the HTML, which to us
mortals looks indistinguishable for the structured XML-ish HTML. Only escaping
things like ampersands. I have put this into Jupyter notebooks where it gets
rendered fine in a web browser. That is no guarantee of success, but we have
experience and understand the finer points.

> I have always been able to assume that the value of htmlsrc is, in fact,
valid html.
> I do think that what goes into the DB should be valid html.
> I think the best solution is to create valid html from the start

That's our common goal. And it should start in the XSL.

> Its not that many more characters to add a </span> rather than making it self
closing is it?

Despite appearances XSL does not have a print() statement. You specify an
output method for the whole stylesheet: text, html, xml. And then the processor
has a bit of a mind of its own. Such as empty elements do or don't form
self-closing tags. For example if I put "<scrpt...../>" into the XSL for
placement in the "result tree", in HTML output is is <scrpt....></scrpt>. (I
spelled that tag name wrong so my message does not get me banned from Google
Groups.)

My turn to be whiney and rant. We need a better testing document if we are
going to have WW problems live in Runestone. I can work on this some, but we
really need the sort of comprehensive testing we get from the sample article and
the sample book. More elsewhere. I have a stack of administrative matters
related to PreTeXt piled up, and I continue to work on Sean's request from
mid-September to get long descriptions going, to say nothing of 14 commits
hanging fire on a branch that will provide significant speed-ups and storage
economies. I have one simple experiment I may try later today.

Rob


On 9/27/23 05:50, Brad Miller wrote:
> Sorry, that was more whiney/ranty than it should have been.
>
> I do think that what goes into the DB should be valid html.  Those fragments are
> used in way too many places and inserted into pages for previewing, grading,
> assignments, etc...  We don't want to have to fix them up when we want to render
> them.  Converting them at the time we process the manifest is an option if we
> can do it reliably.   So, this morning I tried Steven's idea.
>
> from lxml import etree as ET
> from lxml import html
> testfrag = "<div><span id='foo'/>foo bar</div>"
> ET.tostring(html.fromstring(testfrag))
>
> Unfortunately this leaves the span as self closing...
>
> I think the best solution is to create valid html from the start, fixing things
> downstream just feels brittle and error prone (as we are seeing).
>
> Brad
>
> *Bradley Miller, PhD*
> Professor Emeritus Computer Science
> Luther College
> Founder, Runestone Academy LTD <https://runestone.academy>
> Blog: A Reputable Journal <https://www.reputablejournal.com>
> Schedule a Meeting <https://fantastical.app/bonelake-Gj2i/meet-with-brad>
> https://groups.google.com/d/msgid/pretext-dev/e7cfd802-d2e1-45a4-8b88-bc844211a7ec%40Spark <https://groups.google.com/d/msgid/pretext-dev/e7cfd802-d2e1-45a4-8b88-bc844211a7ec%40Spark?utm_medium=email&utm_source=footer>.

Rob Beezer

unread,
Sep 27, 2023, 3:15:36 PM9/27/23
to prete...@googlegroups.com
On 9/27/23 08:19, Rob Beezer wrote:
> I have one simple experiment I may try later today.

OK, simplest possible thing to try. For the creation of the manifest, I
switched the output method from "xml" to "html". And I put a "fillin" into the
text for a "choice" of a multiple-choice exercise.

The resulting "span" has an open element, no content, and a close element. Yahoo!

But all indentation is gone, it is a mess. Sort of as expected, even if it is a
small mystery to me why this happens in other contexts. So right now I can't
see what else significant has changed. I'll need to standardize before and
after with a linter and then compare. But I'm too knackered at the moment.

But perhaps there is an easy fix.

Rob


Rob Beezer

unread,
Sep 28, 2023, 10:26:54 AM9/28/23
to prete...@googlegroups.com
On 9/27/23 12:15, Rob Beezer wrote:
> But all indentation is gone, it is a mess.  Sort of as expected, even if it is a
> small mystery to me why this happens in other contexts.  So right now I can't
> see what else significant has changed.  I'll need to standardize before and
> after with a linter and then compare.

Testing different ways of producing the manifest. XSL output methods "xml"
(status quo), "html" (later?). Added a "fillin" to a "choice" about stop signs.
Search output for "10-character" and you will be there.

Manifests for the sample book. The three linters I used choked on the HTML
version due to "datafile" with monster attributes and RS FITB with embedded
JSON. So I made a "slim" version of the source.

I *could not* get my linters to cooperate and produce an informative diff. I
*do* see the problematic "span" from the "fillin" behaving better with the
"html" method.

Files attached in case somebody can better control line breaks and indentation
identically on these files (as just XML syntax). And for Brad to peruse as the
best evidence I can produce of what this change might cause to happen.

That's it for today - off into the abyss of administrative mode.

Rob
manifest.html
manifest.xml
manifest-slim.html
manifest-slim.xml

Steven Clontz

unread,
Sep 28, 2023, 12:15:28 PM9/28/23
to prete...@googlegroups.com
Bumping this up to ensure my solution (which allows continuing to encode HTML elements as XML elements, should we want to not change how the manifest is generated) was seen:


image.png
--
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.
Reply all
Reply to author
Forward
0 new messages