Giter Site home page Giter Site logo

cssparser's Introduction

DDCSSParser - A C++ CSS Parser

English document

DDCSSParser是一个C++实现的css解析器。最终会生成一系列的selector的模型(Selector类),并且会依据一个Selector判断CSS是否适用于某一个HTML的DOM节点。

Installation

  • 将代码拷贝至本地git clone https://github.com/luojilab/CSSParser.git
  • 提取出来Src文件夹中的内容到工程中

Feature

支持的CSS Selector:

  • Simple Selector:
    • Type Selector
    • Universal Selector
    • Attribute Selector
    • Class Selector
    • ID Selector
  • Selector Sequence
  • Selector Group
  • Combinators:
    • Descendant combinator
    • Child combinators
    • Sibling combinators

不支持的CSS Selector:

  • 伪类(pseudo class)

将要实现的目标:

  • 移除对于Gumbo的依赖
  • 增加对于伪类的支持
  • 增加对于CSS规则的建模
  • 消除可能存在的一些bug

Basic Usage

#include "gumbo.h"
#include "CSSParser.hpp"
#include "GumboInterface.h"
#include "HTMLCSSRefAdaptor.h"

// 建立CSS Selector的模型
future::GumboInterface gi(ptr, "2");
future::CSSParser* parser = new future::CSSParser;
parser->parse("/Path/to/CssFile");
std::list<future::Selector *>selectors = parser>getSelectors();

// 查询CSS某一条规则是否应用到HTML的某一节点上
future::Selector* selector = *selectors.begin();
GumboNode *root = gi.get_root_node();
future::HTMLCSSRefAdaptor::GumboArray nodesArray = &root;
future::HTMLCSSRefAdaptor::nodeAdaptToSelector(&nodesArray, selector);

Dependency

cssparser's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.