I've found that using bs4's "html5lib" parser will preserve case in attribute names. As will sigil_gumbo_bs4_adapter.
Provided the xhtml variable contains markup with svg:
Code:
from sigil_bs4 import BeautifulSoup as bs4
soup=bs4(xhtml, "html5lib")
print(soup.prettify_xhtml())
or
Code:
import sigil_gumbo_bs4_adapter as bs4
soup=bs4.parse(xhtml)
print(soup.prettify_xhtml())