1#!/usr/bin/env python3 2# SPDX-License-Identifier: LGPL-2.1-or-later 3 4from lxml import etree as tree 5 6class CustomResolver(tree.Resolver): 7 def resolve(self, url, id, context): 8 if 'custom-entities.ent' in url: 9 return self.resolve_filename('man/custom-entities.ent', context) 10 11_parser = tree.XMLParser() 12_parser.resolvers.add(CustomResolver()) 13 14def xml_parse(page): 15 doc = tree.parse(page, _parser) 16 doc.xinclude() 17 return doc 18 19def xml_print(xml): 20 return tree.tostring(xml, pretty_print=True, encoding='utf-8') 21