adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
530 stars 127 forks source link

dom.d: Allow modification of selfClosedElements #262

Closed Ssamm45 closed 3 years ago

Ssamm45 commented 4 years ago

When editing XML documents other that HTML there are often self closing tags that are not in current list. It would be useful if it were possible to change what tags are in this list.

adamdruppe commented 4 years ago

yeah i could probably just make an accessor.... it was kinda a mistake to make it global, perhaps i should move it to the Document class.

(now technically in xml IIRC <foo/> is supposed to be totally identical to <foo></foo> so you can write that way too. but otherwise self closing i think comes off the dtd... just i never parse them...)

adamdruppe commented 3 years ago

I finally added a facility. You can do one of two things:

auto doc = new XmlDocument(); // or new Document, it just has a different default
doc.selfClosedElements ~= "whatever";
doc.parse(...)

or make your own list and pass it to things like Element.make.

docs http://dpldocs.info/experimental-docs/arsd.dom.Document.selfClosedElements.html

http://arsd-official.dpldocs.info/arsd.dom.Element.make.html

etc