百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

katana-parser

> 编程语言
开源

一个纯粹的 C99 语言的 CSS 分析库

183 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个纯粹的 C99 语言的 CSS 分析库

Katana - A pure-C CSS parser.

Katana is an implementation of the CSS (Cascading Style Sheet) parsing algorithm implemented as a pure C library with no outside dependencies. It's designed to serve as a building block for other tools and libraries such as linters, validators, templating languages, and refactoring and analysis tools.

Katana is inspired by Gumbo, so it has some goals and features same as Gumbo.

Goals & features:

  • Simple API that can be easily wrapped by other languages.
  • Relatively lightweight, with no outside dependencies.
  • Support for fragment parsing.

Non-goals:

  • Mutability. Katana is intentionally designed to turn a style sheet into a parse tree, and free that parse tree all at once. It's not designed to persistently store nodes or subtrees outside of the parse tree, or to perform arbitrary style mutations within your program. If you need this functionality, we recommend translating the Katana parse tree into a mutable style representation more suited for the particular needs of your program before operating on it.

Wishlist:

  • Fully conformant with the CSS-syntax.
  • Hackable dump or print.
  • Robust and resilient to bad input.
  • Full-featured error reporting.
  • Additional performance improvements.
  • Tested on Official W3C Test Suites.

Installation

To build and install the library, issue the standard UNIX incantation from the root of the distribution:

bash
$ ./autogen.sh
$ ./configure CFLAGS="-std=c99"
$ make
$ sudo make install

Katana comes with full pkg-config support, so you can use the pkg-config to print the flags needed to link your program against it:

bash
$ pkg-config --cflags katana         # print compiler flags
$ pkg-config --libs katana           # print linker flags
$ pkg-config --cflags --libs katana  # print both

For example:

bash
$ gcc examples/dump_stylesheet.c `pkg-config --cflags --libs katana` -o dump

If package katana was not found in the pkg-config search path, perhaps you should add the directory containing katana.pc to the PKG_CONFIG_PATH environment variable as following:

bash
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

See the pkg-config man page for more info.

Basic Usage

Within your program, you need to include "katana.h" and then issue a call to katana_parse:

c
#include "katana.h"

int main() {
  const char* css = "selector { property: value }";
  KatanaOutput* output = katana_parse(css, strlen(css), KatanaParserModeStylesheet);
  // Do stuff with output, eg. print the input style
  katana_dump_output(output);
  katana_destroy_output(output);
}

See the API documentation and sample programs for more details.

Contributing

Bug reports are very much welcome. Please use GitHub's issue-tracking feature, as it makes it easier to keep track of bugs and makes it possible for other project watchers to view the existing issues.

Patches and pull requests are also welcome.

If you're unwilling to do this, it would be most helpful if you could file bug reports that include detailed prose about where in the code the error is and how to fix it, but leave out exact source code.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言