Comments (10)
I guess that it is simply because they define font without the option to define a font-stretch,
See https://www.w3schools.com/cssref/pr_font_font.asp, w3schools defines the structure as:
The font property is a shorthand property for:
- font-style
- font-variant
- font-weight
- font-size/line-height
- font-family
I am usually considering MDN as a more reliable source, either case, the logic in question should be removed.
Let me know if you are OK with that and I will remove the check, the props are already defaulted to 'normal'.
from parse-css-font.
- This appears to be a bug.
- I agree that I should keep track of which tokens are already set and filter them out.
- The logic around this check is the following formal syntax:
[ <'font-style'> || <font-variant-css21> || <'font-weight'> || <'font-stretch'> ]?
. The||
operator combined with?
instead of*
threw me off, misleading me into thinking that only one could be supplied, without repetition.
I'm still quite confused, in fact, because the following CSS doesn't validate:
p {
font: italic small-caps bold expanded 18px/1.4em "open sans", sans-serif;
}
It seems to have a problem with the font-stretch: expanded
part.
Do you have a more human way to interpret how this portion of the formal syntax should operate?
from parse-css-font.
What do you mean by a problem with expanded? this is a valid font,
The part which is confusing in MDN is that each part is optional, but the order is important.
I am thinking that maybe you can remove this part altogether and just default these attributes to "normal",
WDYT?
from parse-css-font.
expanded
is a valid font-stretch
, but it doesn't validate via The W3C CSS Validation Service.
I don't want to guess anything here, so I'm afraid I'm still not 100% comfortable with a solution.
Anyone out there know more about how this works or why my example above is failing CSS validation?
from parse-css-font.
from parse-css-font.
I think that it is the other way around, that MDN is correct.
I tested in a browser and font-stretch is supported, so it seems that W3schools are missing this props and the error is on their side.
from parse-css-font.
Not just W3schools but the W3C validation service is missing it as well. That's what's so disconcerting!
from parse-css-font.
https://codepen.io/jedmao/pen/omxqbv
- Chrome and Firefox both parse the shorthand and convert the
font-stretch
into125%
. - Microsoft Edge does not parse the font shorthand and doesn't even set the font size or anything else as a result of the "error" unless I remove
expanded
.
I think it's safe to say that this package should support the font-stretch
.
from parse-css-font.
According to https://drafts.csswg.org/css-fonts-3/#propdef-font there is a forth property font-strech,
according to https://www.w3.org/TR/CSS2/fonts.html#font-shorthand there isn't, but there is a disclaimer at the bottom that this is not the most up to date, and "Cascading Style Sheets (CSS) — The Official Definition" should be used, So I am guessing that the package should support it.
So do we agree that the logic mentioned at the begining of the thread should be removed?
from parse-css-font.
I'm not sure if removed is the right solution. I think it needs to be changed. First step is to submit a PR with breaking tests.
from parse-css-font.
Related Issues (8)
- If "font" property doesn't have "font-size" or "font-family" error HOT 1
- Doesn't unescape escaped characters HOT 3
- Error parsing `font: inherit` HOT 6
- 58kb bundle size HOT 4
- ES module being exported instead of function HOT 2
- `10px / 1.2` not being handled properly HOT 2
- Parse random font variant HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parse-css-font.