Merge pull request 'Formatter now accepts XMLs with prologs' (#70) from bema/fix/#57 into dev
Reviewed-on: R11/release11-tools-web#70
This commit is contained in:
@@ -7,8 +7,15 @@ def prettify(source: str) -> str:
|
|||||||
:param source: XML
|
:param source: XML
|
||||||
:return: prettified XML
|
:return: prettified XML
|
||||||
"""
|
"""
|
||||||
|
prolog = ""
|
||||||
|
prolog_start = source.find("<?")
|
||||||
|
|
||||||
|
if prolog_start != -1:
|
||||||
|
prolog_end = source.find("?>") + 2
|
||||||
|
prolog = source[prolog_start:prolog_end] + "\n"
|
||||||
|
source = source[prolog_end: ]
|
||||||
xml = etree.XML(source)
|
xml = etree.XML(source)
|
||||||
return etree.tostring(xml, pretty_print=True).decode()
|
return prolog + etree.tostring(xml, pretty_print=True).decode()
|
||||||
|
|
||||||
def minimize(source: str) -> str:
|
def minimize(source: str) -> str:
|
||||||
"""Method used to minimize XML by deleting not needed whitespaces.
|
"""Method used to minimize XML by deleting not needed whitespaces.
|
||||||
|
|||||||
Reference in New Issue
Block a user