Fast C/C++ CSS Parser (Cascading Style Sheets Parser)

Related tags

Miscellaneous mycss
Overview

MyCSS — a pure C CSS parser

MyCSS is a fast CSS Parser implemented as a pure C99 library with the ability to build without dependencies.

By default MyCSS depends of MyHTML library. This is one of module of the Modest project.

Features

Support encodings for InputStream

See MyHTML support encodings

Support encodings for output

Program working in UTF-8 and returns all in UTF-8

Dependencies

MyHTML

Installation

See INSTALL.md

External Bindings and Wrappers

All in our hands!

Examples

See examples directory

Simple example

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <mycss/api.h>

int main(int argc, const char * argv[])
{
    char *css = "#ident [name=\"best-name\"] {rgba(0, 0, 0, 0.1);}";
    
    // base init
    mycss_t *mycss = mycss_create();
    mycss_status_t status = mycss_init(mycss);
    
    // current entry, work init
    mycss_entry_t *entry = mycss_entry_create();
    status = mycss_entry_init(mycss, entry);
    
    mycss_parse(entry, MyHTML_ENCODING_UTF_8, css, strlen(css));
    
    // release resurces
    mycss_entry_destroy(entry, true);
    mycss_destroy(mycss, true);
    
    return 0;
}

AUTHOR

Alexander Borisov [email protected]

COPYRIGHT AND LICENSE

Copyright (C) 2016 Alexander Borisov

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

See the LICENSE file.

You might also like...
A simple implementation of a parser and its use to calculate simple mathematical expressions

Calculator C Parser A simple implementation of a parser and its use to calculate simple mathematical expressions I haven't written a detailed descript

Lightweight C++ command line option parser

Release versions Note that master is generally a work in progress, and you probably want to use a tagged release version. Version 3 breaking changes I

A header only library that provides parser combinators to C++

This is an experimental C++ library for rapidly building parsers. It is inspired by parser combinators in haskell such as attoparsec and, like those libraries, allows for the construction of fully fledged parsers in a few lines of code.

 MiWi RN Command Parser
MiWi RN Command Parser

MiWi RN Command Parser "Wireless Made Easy!" - MiWi RN command parser based on SAMR30 and SAMR21 MiWi example code Devices: | ATSAMR30 | ATSAMR21 ⚠ Di

Modern C++ 20 compile time OpenAPI parser and code generator implementation

OpenApi++ : openapipp This is a proof of concept, currently under active work to become the best OpenAPI implementation for C++. It allows compile tim

OpenAllegroParser - FOSS Parser for Cadence Allegro designs.

OpenAllegroParser Purpose of this project is to provide a C++17 library for parsing Cadence's Allegro binary file formats. This library can be linked

Small Extremely Powerful Header Only C++ Lexical Analyzer/String Parser Library
Small Extremely Powerful Header Only C++ Lexical Analyzer/String Parser Library

lexpp Small Extremely Powerful Header Only C++ Lexical Analyzer/String Parser Library Lexpp is made with simplicity and size in mind. The entire libra

GPS parser which read raw GPS messages, selects only the valid ones and sends them to CAN bus

EagleTRT GPS System for Fenice GPS parser which read raw GPS messages, selects only the valid ones and sends them to CAN bus Compiling GPS Logger gps_

Ctpg - Compile Time Parser Generator

Ctpg - Compile Time Parser Generator is a C++ single header library which takes a language description as a C++ code and turns it into a LR1 table parser with a deterministic finite automaton lexical analyzer, all in compile time.

Comments
  • Fixed Makefiles for correct include order of static libraries, fixed …

    Fixed Makefiles for correct include order of static libraries, fixed …

    …error about unused 'status' variable by actually checking the status in the examples and in the test.

    This fixes all the build errors I had with the library.

    opened by ghost 1
  • Failed to make mycss with latest myhtml - please sync with modest

    Failed to make mycss with latest myhtml - please sync with modest

    Ubuntu 14.04 gcc version 4.8.5 branch: master

    Running make returns with error when linked to latest myhtml.

    • first I cloned latest mycss and myhtml
    • build myhtml without error
    • then running make on mycss linking to myhtml: LDFLAGS+="-L../../../myhtml/lib" CFLAGS+="-I../../../myhtml/include" /usr/bin/make -C mycss

    returns with error:

    cc -I../../../myhtml/include -O2 -fPIC --std=c99 -I.. -pthread -D_POSIX_C_SOURCE=199309L   -c -o an_plus_b.o an_plus_b.c
    In file included from ../mycss/entry.h:29:0,
                     from ../mycss/an_plus_b.h:29,
                     from an_plus_b.c:21:
    ../mycss/myosi.h:263:48: error: unknown type name ‘myhtml_string_t’
     typedef size_t (*mycss_string_process_state_f)(myhtml_string_t* str, const char* data, size_t length, size_t size, mycss_string_res_t *out_res);
                                                    ^
    In file included from ../mycss/mycss.h:45:0,
                     from ../mycss/entry.h:30,
                     from ../mycss/an_plus_b.h:29,
                     from an_plus_b.c:21:
    ../mycss/tokenizer.h:36:29: fatal error: myhtml/incoming.h: No such file or directory
     #include "myhtml/incoming.h"
    

    I noticed that the repo for Modest actually includes all myhtml and mycss sources. So my guess is that the current mycss repo is not up to date since it also includes "myhtml/incoming.h" which is now in "mycore".

    Can you please update the repo with the latest source? That would be great!

    Best, f34nk

    opened by f34nk 0
  • I dont know url is represent for a background or a font etc

    I dont know url is represent for a background or a font etc

    Hi I reviewed the example code and some header files. I care about url inside the css. But I think I dont know the url is represent for a font or background img etc. is there any way?

    opened by cg82616424 12
  • Many properties are not recognized

    Many properties are not recognized

    I am noticing that many properties are not recognized. Simple properties like 'color' or 'border-radius' just are not showing up in the declarations.

    If all the declarations are of the non-supported type, the mycss_selectors_list_t::declaration_entry property is set to NULL (which should never happen IMHO).

    opened by ghost 1
Owner
Alexander
Alexander
A distribution of the cFS that includes the cfe-eds-framework which includes NASA's core Flight Executive(cFE) and CCSDS Electronic Data Sheets(EDS) support.

core Flight System(cFS) Application Toolkit(cFSAT) - Beta Release A distribution of the cFS that includes the cfe-eds-framework which includes NASA's

OpenSatKit 13 Jul 3, 2022
List of Persian Colors and hex colors for CSS, SCSS, PHP, JS, Python, and Ruby.

Persian Colors (Iranian colors) List of Persian Colors and hex colors for CSS, SCSS, PHP, C++, QML, JS, Python, Ruby and CSharp. Persian colors Name H

Max Base 12 Sep 3, 2022
Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development

Go bindings for Sciter Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust). Attention The ownership of project is tra

Terra Informatica Software, Inc 2.5k Dec 23, 2022
Functional programming style pattern-matching library for C++

Mach7: Pattern Matching for C++ by Yuriy Solodkyy, Gabriel Dos Reis, Bjarne Stroustrup Abstract Pattern matching is an abstraction mechanism that can

Yuriy Solodkyy 1.2k Dec 26, 2022
Single header lib for JPEG encoding. Public domain. C99. stb style.

tiny_jpeg.h A header-only public domain implementation of Baseline JPEG compression. Features: stb-style header only library. Does not do dynamic allo

Sergio Gonzalez 212 Dec 14, 2022
An old-style web browser stub, comes from Internet Explorer was genocided on Windows.

Outernet Explorer An old-style web browser stub, comes from Internet Explorer was genocided on Windows. Download from: https://github.com/kekyo/Outern

Kouji Matsui 11 Oct 14, 2022
Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics.

Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics Table of contents Introduction Documen

Gianluca Bianco 168 Dec 20, 2022
official repository of the muparser fast math parser library

muparser - Fast Math Parser 2.3.3 (Prerelease) To read the full documentation please go to: http://beltoforion.de/en/muparser. See Install.txt for ins

Ingo Berg 301 Dec 22, 2022
Fast, gpu-based CSV parser

nvParse Parsing CSV files with GPU Parsing delimiter-separated files is a common task in data processing. The regular way of extracting the columns fr

Anton 545 Dec 20, 2022
Peregrine - A blazing fast language for the blazing fast world(WIP)

A Blazing-Fast Language for the Blazing-Fast world. The Peregrine Programming Language Peregrine is a Compiled, Systems Programming Language, currentl

Peregrine 1.5k Jan 2, 2023