Skip to content

Commit cd2e954

Browse files
committed
Initial draft of IDL.
1 parent 2a5603b commit cd2e954

File tree

1 file changed

+115
-10
lines changed

1 file changed

+115
-10
lines changed

css-parser-api/Overview.bs

+115-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,119 @@
11
<pre class='metadata'>
2-
Title: CSS Parser API Level 1
3-
Status: DREAM
4-
Group: houdini
5-
ED: https://drafts.css-houdini.org/css-parser-api-1/
2+
Title: CSS Parser API
63
Shortname: css-parser-api
74
Level: 1
8-
Abstract: This specification is not currently being worked on in the Houdini TF. Instead, it will be worked on in a WICG repository. This document will link to that repository once it exists.
9-
Editor: Tab Atkins, jackalmage@gmail.com
10-
Editor: Shane Stephens, shanestephens@google.com
11-
Editor: Daniel Glazman, danie.glazman@disruptiveinnovations.com
12-
Editor: Brian Kardell, bkardell@gmail.com
13-
Warning: Replaced by http://example.com/filler-url
5+
Status: UD
6+
Group: HOUDINI
7+
URL: https://drafts.css-houdini.org/css-parser-api/
8+
Editor: Tab Atkins-Bittner
9+
Abstract: An API exposing the CSS parser more directly,
10+
Abstract: for parsing arbitrary CSS-like languages into a mildly typed representation.
11+
</pre>
12+
13+
Introduction {#intro}
14+
=====================
15+
16+
Common data-interchange / parsing formats are very valuable
17+
for reducing the learning curve of new languages,
18+
as users get to lean on their existing knowledge of the format when authoring
19+
and only have to newly learn the specifics of the language.
20+
This is why generic parsing formats like XML or JSON have become so popular.
21+
22+
The CSS language could benefit from this same treatment;
23+
a number of languages and tools rely on CSS-like syntax to express themselves,
24+
but they usually rely on ad-hoc parsing
25+
(often regex-based)
26+
which can be relatively fragile,
27+
and might break with CSS practices in interesting syntax corner cases.
28+
Similarly, CSS syntax is increasingly used in places like attribute values
29+
(such as the <{img/sizes}> attribute,
30+
or most of the SVG presentation attributes),
31+
and custom elements wanting to do the same thing
32+
similarly have to rely on ad-hoc parsing right now.
33+
34+
To help with these sorts of cases,
35+
this spec exposes the [[!css-syntax-3]] parsing algorithms,
36+
and represents their results in a mildly-typed representation,
37+
simpler and more abstract than what [[css-typed-om-1]] does for CSS properties.
38+
39+
Parsing API {#parsing-api}
40+
==========================
41+
42+
<pre class=idl>
43+
partial interface CSS {
44+
sequence&lt;CSSParserRule> parseStylesheet(DOMString css, optional CSSParserOptions options);
45+
sequence&lt;CSSParserRule> parseRuleList(DOMString css, optional CSSParserOptions options);
46+
CSSParserRule parseRule(DOMString css, optional CSSParserOptions options);
47+
sequence&lt;(CSSParserDeclaration or CSSParserRule)> parseDeclarationList(DOMString css, optional CSSParserOptions options);
48+
CSSParserDeclaration parseDeclaration(DOMString css, optional CSSParserOptions options);
49+
(CSSParserValue or DOMString) parseValue(DOMString css);
50+
sequence&lt;(CSSParserValue or DOMString)> parseValueList(DOMString css);
51+
sequence&lt;sequence&lt;(CSSParserValue or DOMString)>> parseCommaValueList(DOMString css);
52+
};
53+
54+
dictionary CSSParserOptions {
55+
object atRules;
56+
boolean enforceCSSGrammar = false;
57+
};
58+
</pre>
59+
60+
Parser Values {#parser-values}
61+
==============================
62+
63+
<pre class=idl>
64+
interface CSSParserRule {
65+
66+
};
67+
68+
interface CSSParserAtRule : CSSParserRule {
69+
70+
};
71+
72+
interface CSSParserQualifiedRule : CSSParserRule {
73+
74+
};
75+
76+
interface CSSParserDeclaration {
77+
78+
};
79+
80+
interface CSSParserValue {
81+
82+
};
83+
84+
interface CSSParserBlock : CSSParserValue {
85+
86+
};
87+
88+
interface CSSParserFunction : CSSParserValue {
89+
90+
};
91+
92+
interface CSSParserIdent : CSSParserValue {
93+
94+
};
95+
96+
interface CSSParserNumber : CSSParserValue {
97+
98+
};
99+
100+
interface CSSParserPercentage : CSSParserValue {
101+
102+
};
103+
104+
interface CSSParserDimension : CSSParserValue {
105+
106+
};
107+
108+
interface CSSParserAtKeyword : CSSParserValue {
109+
110+
};
111+
112+
interface CSSParserHash : CSSParserValue {
113+
114+
};
115+
116+
interface CSSParserString : CSSParserValue {
117+
118+
};
14119
</pre>

0 commit comments

Comments
 (0)