|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | -import pytidyhtml5 |
| 3 | +from pytidyhtml5 import AttrSortStrategy, LineEnding, OptionId, set_language, tidy_document |
| 4 | + |
| 5 | + |
| 6 | +options = { |
| 7 | + OptionId.alt_text: '', |
| 8 | + OptionId.doctype: 'html5', |
| 9 | + OptionId.drop_empty_elems: False, |
| 10 | + OptionId.drop_empty_paras: False, |
| 11 | + OptionId.fix_backslash: False, |
| 12 | + OptionId.force_output: True, |
| 13 | + OptionId.hide_comments: True, |
| 14 | + OptionId.html_out: True, |
| 15 | + OptionId.indent_attributes: False, |
| 16 | + OptionId.indent_cdata: False, |
| 17 | + OptionId.indent_content: False, |
| 18 | + OptionId.indent_spaces: 0, |
| 19 | + OptionId.join_classes: True, |
| 20 | + OptionId.join_styles: True, |
| 21 | + OptionId.mark: False, |
| 22 | + OptionId.merge_divs: False, |
| 23 | + OptionId.merge_emphasis: False, |
| 24 | + OptionId.merge_spans: False, |
| 25 | + OptionId.meta_charset: True, |
| 26 | + OptionId.newline: LineEnding.crlf, |
| 27 | + OptionId.num_entities: True, |
| 28 | + OptionId.quote_ampersand: True, |
| 29 | + OptionId.quote_marks: True, |
| 30 | + OptionId.quote_nbsp: True, |
| 31 | + OptionId.sort_attributes: AttrSortStrategy.alpha, |
| 32 | +} |
| 33 | + |
| 34 | +set_language('de') |
4 | 35 |
|
5 | | -pytidyhtml5.set_language('de') |
6 | 36 | expected = ( |
7 | | - '<!DOCTYPE html>\n<html>\n<head>\n<meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">\n<title></title>\n</head>\n<body>\nHallöchen\n</body>\n</html>\n', |
8 | | - "Zeile 1 Spalte 1 - Warnung: fehlende <!DOCTYPE> Deklaration\nZeile 1 Spalte 1 - Warnung: Klartext ist im Element <head> nicht erlaubt\nZeile 1 Spalte 1 - Info: <head> bereits vermerkt\nZeile 1 Spalte 1 - Warnung: füge implizites <body> ein\nZeile 1 Spalte 1 - Warnung: füge fehlendes 'title' Element ein\n" |
| 37 | + '<!DOCTYPE html>\r\n<html>\r\n<head>\r\n<meta charset="utf-8">\r\n<title></title>\r\n</head>\r\n<body>\r\nHallöchen\r\n</body>\r\n</html>\r\n', |
| 38 | + "Zeile 1 Spalte 1 - Warnung: fehlende <!DOCTYPE> Deklaration\nZeile 1 Spalte 1 - Warnung: Klartext ist im Element <head> nicht erlaubt\nZeile 1 Spalte 1 - Info: <head> bereits vermerkt\nZeile 1 Spalte 1 - Warnung: füge implizites <body> ein\nZeile 1 Spalte 1 - Warnung: füge fehlendes 'title' Element ein\nZeile 1 Spalte 10 - Info: Fehlendes <meta charset=...> wurde in <head> hinzugefügt\n", |
9 | 39 | ) |
10 | | -actual = pytidyhtml5.tidy_document('Hallöchen') |
| 40 | +actual = tidy_document('Hallöchen', options=options) |
| 41 | + |
11 | 42 | if expected != actual: |
12 | 43 | print('actual=' + repr(actual)) |
13 | 44 | raise SystemExit(1) |
|
0 commit comments