1 # Stricter version of the export tests: validate the XHTML code produced by
2 # LyX' lyxhtml output as HTML5. It also validates the CSS and MathML parts.
3 # Validation errors usually are mistakes in the generator.
6 # python simplehtml_validity.py PATH_TO_HTML5_SOURCE
8 # Written with Python 3.8.8.
10 # - Python package: html5validator: at least v0.4.2
11 # - Java runtime engine (JRE): at least v8 (depending on html5validator)
13 # pip install html5validator>=0.4.2
21 if len(sys.argv) != 2:
22 print('Expecting one argument, the path to the LyX-created XHTML file')
24 if not os.path.exists(sys.argv[1]):
25 print('The given path does not point to an existing file')
29 xhtml_file_name = sys.argv[1]
30 xhtml_list = [xhtml_file_name]
32 validator = html5validator.Validator(format='text')
33 error_count = validator.validate(xhtml_list)
38 print('> Found a validation error!')