w3c / sparql-query

https://w3c.github.io/sparql-query/
Other
9 stars 0 forks source link

Special typesetting of formulas #103

Open hartig opened 1 year ago

hartig commented 1 year ago

As suggested by @TallTed, formulas and mathematical functions should be typeset in a way that looks different from the regular text. Quoting @TallTed's comment:

Is there another tag that should be used? Or another class to apply to such code tags, similar to what @afs mentioned for sparql code highlighting?

Formulas and mathematical functions that are written up in textbooks on these and related subjects are not generally printed using body text (nor, admittedly, monospaced/typewriter) styles. I have hopes we can come close with what we produce.

Related to this issue, and captured as #102, is that the symbols used for variables in such formulas should be marked up using <var> (or |) .

hartig commented 1 year ago

Here is my take on the following questions.

Is there another tag that should be used? Or another class to apply to such code tags, similar to what @afs mentioned for sparql code highlighting?

I would not use <code> tags because formulas and mathematical functions are not code. As there does not seem to exist a special HTML tag for marking up math content, I would simply use <span> with a specific CSS class that renders the content to look slightly different from the regular text.

gkellogg commented 1 year ago

Have you considered using the math Elment the ReSpec? https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#

I often use the var element for variables, which may get you part of the way there.

TallTed commented 1 year ago

var definitely helps.

At first blush, <math> looks like the right direction from there, but I'm concerned that this may require a lot more complex MathML markup. Does anyone here have experience using MathML in such a simplistic way as I think we're contemplating? Is it really as simple as adding a leading <math display="block"> or <math display="inline">, and a trailing </math>?

afs commented 1 year ago

Could we have some concrete displaying HTML please? (not sure what github tech allows easy raw HTML without interference).

Tpt commented 1 year ago

Sadly Github does not seems to support Mathml in comments. Here is a getting started on MDN.

TallTed commented 1 year ago

Ugh. The compatibility table claims Chrome 109+ support MathML, but the <mfrac> sample displays as 1 3 in my Version 114.0.5735.133 (Official Build) (x86_64). I think that means <math> is a lose.

hartig commented 1 year ago

I want to suggest to postpone taking action on this issue here until #105 #106 #107 and #94 are addressed. Each of these issues touches on parts that contain formulas and, thus, PRs for these issues would likely cause merge conflicts with a PR for the issue here.

afs commented 1 year ago

Please include SPARQL-specific CSS classes when the changes do happen. It isolates the docs from browser and reSpec defaults if we need to have specific control.

gkellogg commented 1 year ago

On a recent semantics call, it was noted that the formula presentation in Notation3 Semantics was something that could be emulated. However, this makes use of a JavaScript library to perform runtime rendering of text spans. Ultimately, this results in Unicode styled with CSS, so the presentation can be emulated at some cost to developers.

Another thing to consider would be to use such a package, but have it run as part of the document load event, similar to how examples are marked up so that the styled HTML is rendered during the ReSpec run.