New version of CSSParser with an actual interface attached!
Okay I have pushed the following files to Sigil in my github tree: Misc/CSSParser.cpp and .h, Misc/CSSProperties.cpp and .h and Misc/CSSUtils.cpp and .h.
These use only std:: cpp string manipulation. They have only been integrated into the Sigil build but they are not being used yet.
For those who want to play around with the command line version of the parser to see how it works, I have attached a cssparser.zip file here with a very simple main.cpp and Makefile so that others can try building it.
unzip cssparser.zip
cd cssparser
make
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 the print_css routine in CSSParser.cpp to see how easy it is to add routines to get exactly what you want (for this problem we will want to the list of the selectors).
Check out the main.cpp to get the CSSParser interface example.
It should build easily on macOS and Linux and a Windows build should be doable with a bit more work.
Any testing and feedback or windows build tweaks welcomed.
Last edited by KevinH; 01-07-2021 at 08:46 AM.
Reason: Added new expanded version of cssparser.zip
|