openstax / css-manipulate

Do more with CSS!
https://jsfiddle.net/philschatz/hjk2z4af/
5 stars 0 forks source link

support xml files #8

Closed philschatz closed 6 years ago

philschatz commented 6 years ago

This library can work with arbitrary XML files but since it uses headless chrome those files need to be wrapped in <html><body> so chrome uses the XHTML renderer (rather than just rendering the XML tree which isn't really queryable).

TODO

/cc @aiwenar because you are using this to manipulate CNXML and @reedstrm to think about when writing the python port 😄

aiwenar commented 6 years ago

It no longer fails to load non-xhtml fragments, which is good, but there's still a big problem: it'll fail if the source contains XML declaration, because (quoting chrome)

error on line 2 at column 6: XML declaration allowed only at the start of the document

Also, css-plus will not report this problem and exit with code 0, making it necessary to inspect all output files manually.

aiwenar commented 6 years ago

While the XML declaration problem is easy to circumvent, #10 unfortunately makes css-plus still unusable for XML manipulation.

philschatz commented 6 years ago

This now fixes most of the cases listed in #10 (except <c>). I can revisit <c> if it is a problem in a subsequent Pull Request.