nathell / clj-tagsoup

A HTML parser for Clojure.
Other
181 stars 22 forks source link

Attributes get lowercased; xmlns omitted #8

Open nchurch opened 11 years ago

nchurch commented 11 years ago

I tried parsing some Android XML configuration files; these have attributes, for instance, like

android:keyWidth="15%p" android:horizontalGap="0px"
android:verticalGap="0px"

clj-tagsoup lowercases the attribute names-----e.g.:

android:keywidth

so that it doesn't roundtrip through Hiccup.

Additionally, it doesn't pick up the xmlns declaration in the root element; e.g:

xmlns:android="http://schemas.android.com/apk/res/android"

This has to be put back in by hand.

(I'm using Android as an example, but presumably these issues have relevance beyond Android.)

Thanks,

Nick.

kurt-o-sys commented 6 years ago

+1

Same issue with svg parsing: viewBox is changed to viewbox, which is not valid for svg, giving an error. Could lowercasing be optional?

dimovich commented 5 years ago

You could fix the lowercase :viewbox like this:

(-> (pl.danieljanus.tagsoup/parse-string svg-string)
    (update 1 clojure.set/rename-keys {:viewbox :viewBox}))

I wonder @nathell, is the lowercasing done in clj-tagsoup or in some underlying library?