Is there a CSS parser for C#? [closed]

2019-01-02 18:04发布

My program need to parse css files into an in-memory object format. Any advice on how this should be done ?

标签: c# css parsing
6条回答
残风、尘缘若梦
2楼-- · 2019-01-02 18:15

And a slightly slower search turns up the blog post "CSS parser class in .NET" which embeds this gist on GitHub (in case the blog ever dies).

查看更多
永恒的永恒
3楼-- · 2019-01-02 18:18

I wrote one, using the grammar specified in the CSS 2.1 spec. I have also released it now: for details, see http://www.modeltext.com/css/

查看更多
梦醉为红颜
4楼-- · 2019-01-02 18:30

Here you can find another one especially for C# with sample source.

查看更多
姐姐魅力值爆表
5楼-- · 2019-01-02 18:31

ExCSS (supports CSS2.1 and CSS3) on GitHub: https://github.com/TylerBrinks/ExCSS.

Which is a newer version of the code project article: http://www.codeproject.com/KB/recipes/CSSParser.aspx

查看更多
浮光初槿花落
6楼-- · 2019-01-02 18:35

There is a CSS grammar file for GoldParser:

http://goldparser.org/grammars/files/css.zip

GoldParser is easy to include in a C# project, and generates an real LALR parser - not some regex hack.

查看更多
浅入江南
7楼-- · 2019-01-02 18:35

Have you tried the one featured in JsonFx? It's written in C#, parses CSS3 syntax and is distributed under a MIT style license.

查看更多
登录 后发表回答