Steve Litt via lyx-users said on Fri, 25 Mar 2022 18:09:56 -0400
>And please make the output well-formed XML as well as HTML5. HTML5 can, >but doesn't have to be, well formed XML. It's a couple orders of >magnitude easier to deal with if the exported HTML has all opening tags >accompanied by closing tags, and for tags that both open and close >(<br/> for instance), be sure to put the trailing slash. The following simple Python3 program checks to make sure the file that is its argument is well-formed XML. It's also attached as an attachment. By using this program on LyX' HTML exports, you can verify that the HTML is also well formed XML. ================================================== #!/usr/bin/python3 # Copyright 2017 by Steve Litt # Expat license: https://directory.fsf.org/wiki/License:Expat import sys import re import xml.etree.ElementTree as ET fname = sys.argv[1] print('\nTesting for well formedness {} ...\n'.format(fname)) try: tree = ET.parse(fname) except ET.ParseError as err: (line, col) = err.position code = str(err.code) errmsg = 'ERROR: {}'.format(str(err)) print(errmsg) if re.search(' ', errmsg): print('Replace all with   to solve problem.') print('\n') sys.exit(1) else: print('Congrats, {} is well formed!'.format(fname)) print('') ================================================== SteveT Steve Litt March 2022 featured book: Making Mental Models: Advanced Edition http://www.troubleshooters.com/mmm
#!/usr/bin/python3 # Copyright 2017 by Steve Litt # Expat license: https://directory.fsf.org/wiki/License:Expat import sys import re import xml.etree.ElementTree as ET fname = sys.argv[1] print('\nTesting for well formedness {} ...\n'.format(fname)) try: tree = ET.parse(fname) except ET.ParseError as err: (line, col) = err.position code = str(err.code) errmsg = 'ERROR: {}'.format(str(err)) print(errmsg) if re.search(' ', errmsg): print('Replace all with   to solve problem.') print('\n') sys.exit(1) else: print('Congrats, {} is well formed!'.format(fname)) print('')
-- lyx-users mailing list lyx-users@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-users