Skip to content

[css mode] add support for @counter-style#3084

Closed
KwanEsq wants to merge 5 commits intocodemirror:masterfrom
KwanEsq:css-at-counter-style-2
Closed

[css mode] add support for @counter-style#3084
KwanEsq wants to merge 5 commits intocodemirror:masterfrom
KwanEsq:css-at-counter-style-2

Conversation

@KwanEsq
Copy link
Copy Markdown
Contributor

@KwanEsq KwanEsq commented Feb 15, 2015

The CSS3 Counter Style spec has reached CR, and Firefox has implemented it. Therefore I'd like to add it to the CSS mode.
My first attempt just naïvely added the descriptors to the keywords, but I didn't like how this meant they were highlighted everywhere. Fortunately I then realised/noticed you'd already implemented @font-face in an isolated way that'd be perfect for @counter-style. Thus this second attempt, which I'm much happier with.
Main issues/questions:
Is the way I'm propagating what type of block it is in, via state.restrictedType, okay? I couldn't see any pre-existing way to access that data, but maybe I just missed it. And should it be named something else? I could see the same approach being useful for distinguishing regular at-blocks in future, should the property be named the same for both?
Is the way I'm handling counter-style names in restricted_atBlock_before correct?

Add support for @counter-style blocks by making them and @font-face
blocks match a new "restricted_atBlock" state based on "font_face"
Add the values for the @counter-style descriptors 'system' and
'speak-as' to the valueKeywords array
[additive, alphabetic, bullets, cyclic, extends, numbers, numeric,
spell-out, symbolic, words]
fixed (for 'system'), and infinite (for 'range') already present
Add the predefined counter styles from CSS Counter Styles Level 3 that
aren't already included

[cjk-decimal, disclosure-closed, disclosure-open, ethiopic-numeric,
japanese-formal, japanese-informal, korean-hangul-formal,
korean-hanja-formal, korean-hanja-informal, simp-chinese-formal,
simp-chinese-informal, tamil, trad-chinese-formal,
trad-chinese-informal]
@KwanEsq KwanEsq force-pushed the css-at-counter-style-2 branch from 4d55d7e to e0ef414 Compare February 15, 2015 19:08
@KwanEsq KwanEsq force-pushed the css-at-counter-style-2 branch from e0ef414 to 0c1ad05 Compare February 15, 2015 19:10
marijnh added a commit that referenced this pull request Feb 17, 2015
And don't call delete on the state object.

Issue #3084
@marijnh
Copy link
Copy Markdown
Member

marijnh commented Feb 17, 2015

Looks good. Merged, and modified slightly in attached patch, with the intent to have a stateArg property dedicated to keeping local state, so that we don't end up adding more and more state properties for specific purposes. I've removed the delete use, since on some JS engines that still causes objects to become slow general dictionaries, which we don't want to happen for the state object.

@marijnh marijnh closed this Feb 17, 2015
@KwanEsq KwanEsq deleted the css-at-counter-style-2 branch June 20, 2018 01:35
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

Successfully merging this pull request may close these issues.

2 participants