View Single Post
Old 01-06-2021, 11:38 AM   #41
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,849
Karma: 6120478
Join Date: Nov 2009
Device: many
cssparser_v1.1.zip

Okay, for those playing along with the new cssparser code here is version 1.0 with a reasonable interface.

unzip cssparser_v1.1.zip
cd cssparser
make (on Windows use nmake from a Visual Studio command prompt(
cd release/cssparser
./cssparser PATH_TO_STANDALONE_EXISTING_CSS_FILE

It will parse the whole thing and then spit it back all cleaned up. It stores the entire parser css as a vector of tokens that have a type indicator and string data piece associated with each.

Check out main.cpp to see the CSSParser interface example. It now can now:

- set css level to use
- parse a passed in std::string which is the contents of a css file
- check for errors, warnings, and information messages so it can do validation
- walk though the parsed tokens to enable post processing
- and pretty print back the results of the parse

It should build easily on macOS and Linux and Window (thanks to DiapDealer for Makefile.win32).


Any testing and welcomed.

ps. The 1.1 versions of the main files have also been pushed to my personal github Sigil repo.
If you just want to see the source you can look at:

Sigil/src/Misc/CSSParser.cpp and .h
Sigil/src/Misc/CSSProperties.cpp and .h
Sigil/src/Misc/CSSUtils.cpp and .h

at https://github.com/kevinhendricks/Sigil

Last edited by KevinH; 01-11-2021 at 12:01 PM. Reason: Removed zip, see a later post for an improved version
KevinH is offline   Reply With Quote