Created json formatter and validator. #82
@@ -7,8 +7,15 @@ def prettify(source: str) -> str:
 | 
			
		||||
    :param source: 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)
 | 
			
		||||
    return etree.tostring(xml, pretty_print=True).decode()
 | 
			
		||||
    return prolog + etree.tostring(xml, pretty_print=True).decode()
 | 
			
		||||
 | 
			
		||||
def minimize(source: str) -> str:
 | 
			
		||||
    """Method used to minimize XML by deleting not needed whitespaces.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user