Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison edition: 4.4: MathJax rendering within JS confused by $pattern_variables #904

Open
cben opened this issue Jul 5, 2023 · 1 comment

Comments

@cben
Copy link

cben commented Jul 5, 2023

The logic programming patterns in section 4.4 used ?foo for variables in Scheme and $foo in JS.
That's a great choice, as dollar is the only punctuation char valid in JS identifiers, and alludes to $var syntaxes in shells/Perl/etc. 👍

Alas, in the comparison edition, the dollars confuse MathJax, which apparently processes the whole page, including all JS code :-(

here is a particularly mixed-up example, where same list( is sometimes literal code sometimes italic "math", and underscore in lives_near makes the letter n subscript — and most importantly all the dollars are gone.

Screenshot $lives_near
rendered from this XML:

<JAVASCRIPT>
and(job($x, list("computer", "programmer")),
lives_near($x, list("Bitdiddle", "Ben")))
</JAVASCRIPT>

(same happens in later subsections 4.4.2 and so on.)


Now, you can't just exclude all Scheme/JS snippets from mathjax processing, cause some are deliberate, like here:
Screenshot query_1, ..., query_n

<JAVASCRIPT>
In general,
<SNIPPET LATEX="yes">
<JAVASCRIPT>
and(<META>query</META>$_{1}$, <META>query</META>$_{2}$, $\ldots$, <META>query</META>$_{n})$
</JAVASCRIPT>
</SNIPPET>
is
<INDEX>satisfy a compound query<OPEN/></INDEX>
satisfied by all sets of values for the pattern variables that
simultaneously satisfy
<META>query</META><LATEXINLINE>$_{1}, \ldots,$</LATEXINLINE> <META>query</META><LATEXINLINE>$_{n}$</LATEXINLINE>.
</JAVASCRIPT>

So it has to depend on LATEX="yes" attribute.

@cben
Copy link
Author

cben commented Jul 5, 2023

The JS-only edition looks fine BTW: https://sourceacademy.org/sicpjs/4.4.1#p20
There code is code, dollars are dollars, all monospace, yet the LATEX="yes" portions do get rendered with KaTeX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant