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

Trimming of whitespace in attribute #165

Open
fred-wang opened this issue Jul 31, 2019 · 5 comments
Open

Trimming of whitespace in attribute #165

fred-wang opened this issue Jul 31, 2019 · 5 comments

Comments

@fred-wang
Copy link
Contributor

fred-wang commented Jul 31, 2019

This was mentioned in w3c/mathml#63

From https://w3c.github.io/mathml/#syntax-notation-used-in-the-mathml-specification :

"Since some applications are inconsistent about normalization of whitespace, for maximum interoperability it is advisable to use only a single whitespace character for separating parts of a value. Moreover, leading and trailing whitespace in attribute values should be avoided."

Currently MathML Core does not say anything about leading/trailing whitespace in attributes. I think we should be explicit about this. Do we allow them or not?

The non-normative RelaxNG schema is inconsistent ( https://github.com/mathml-refresh/mathml-schema/tree/master/rnc ), sometimes they are allowed, sometimes they are not.

Reminder: In w3c/mathml#21 we agree to align definition on HTML5/CSS.

@fred-wang
Copy link
Contributor Author

Regarding the "separating part of value", I guess we should rely on definitions from https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#space-separated-tokens (see w3c/mathml#104 for menclose, which I think is the only one in mathml core?). These definitions explicitly says they may have leading or trailing ASCII whitespace.

https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#comma-separated-tokens also has "optionally surrounded by ASCII whitespace".

@fred-wang
Copy link
Contributor Author

We currently have a few attributes implemented in the UA stylesheet:
https://mathml-refresh.github.io/mathml-core/#user-agent-stylesheet

(From our experience in Chromium implementation, most of the rules can probably be moved to the C++ code, except maybe the one about accentunder="true" for math-script-level ?)

I don't see anything in https://drafts.csswg.org/selectors-4/#attribute-selectors that would allow trailing/leading whitespace.

Note: the "i" makes values case insensitive https://drafts.csswg.org/selectors-4/#attribute-case

@fred-wang
Copy link
Contributor Author

So my proposal for now is to modify

https://mathml-refresh.github.io/mathml-core/#types-for-mathml-attribute-values

to be explicit that "length-percentage" and "color" attributes accept optional ASCII whitespace (https://infra.spec.whatwg.org/#ascii-whitespace) at the start/end. This matches the RelaxNG MathML3 schema as well as Gecko/WebKit/Blink implementations.

For other attributes the situation is a bit more inconsistent, so let's wait a bit before making the syntax less strict.

@fred-wang
Copy link
Contributor Author

Attributes that can't handle whitespace trimming:

mathml-core/user-agent-stylesheet$ grep '=' *
math.css:math[display="block" i] {
math.css:math[display="inline" i] {
mtable-frame.css:mtable[frame="none" i] {
mtable-frame.css:mtable[frame="solid" i] {
mtable-frame.css:mtable[frame="dashed" i] {
scripts.css:munder[accentunder="true" i] > :nth-child(2),
scripts.css:mover[accent="true" i] > :nth-child(2),
scripts.css:munderover[accentunder="true" i] > :nth-child(2),
scripts.css:munderover[accent="true" i] > :nth-child(3) {
scripts.css:mover[accent="true" i] > :first-child,
scripts.css:munderover[accent="true" i] > :first-child {

@fred-wang
Copy link
Contributor Author

@davidcarlisle I believe this one should still be transferred to mathml-core.

@davidcarlisle davidcarlisle transferred this issue from w3c/mathml Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant