from conftest import Book, Doc def test_nested_lists_keep_structure(convert): body = ("

L

  1. vier
  2. fünf
") text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001") assert "- Eins\n\n 1. Unterpunkt A\n\n 2. Unterpunkt B\n\n - tief\n\n- Zwei" in text assert "4. vier\n5. fünf" in text def test_simple_table_as_gfm(convert): body = ("

T

" "
Tabelle 1: Werte
NameWert
a1 | 2
bx
") text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001") assert "*Tabelle 1: Werte*" in text assert "| Name | Wert |\n| --- | --- |\n| *a* | 1 \\| 2 |\n| b | `x` |" in text def test_complex_table_kept_as_html_with_warning(convert): body = ("

T

Kopf
A

Zeile 1

" "

Zeile 2

B
") run = convert(Book(docs=[Doc("c.xhtml", body)])) text = run.chapter("001") assert 'Kopf' in text assert 'A' in text assert "Zeile 1" in text and "Zeile 2" in text and "B" in text assert "\n\n" not in text.split("")[1].split("
")[0] # HTML block must not be interrupted assert any(w["code"] == "table-html" for w in run.report["warnings"]) def test_commonmark_uses_html_tables(convert): body = "

T

a
b

alt

" text = convert(Book(docs=[Doc("c.xhtml", body)]), "--format", "commonmark").chapter("001") assert "" in text and "| a |" not in text assert "alt" in text def test_definition_list_blockquote_and_inline_semantics(convert): body = ("

D

Term
Erklärung.

Zitat

weiter

" "

H2O, x2, Zitat, weg, unter
neue Zeile


") text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001") assert "**Term:** Erklärung." in text assert "> Zitat\n>\n> weiter" in text assert "H2O, x2, „Zitat“, ~~weg~~, unter\\\nneue Zeile" in text assert "* * *" in text def test_markdown_special_characters_are_escaped(convert): body = "

E

1. kein Listenpunkt

# keine Überschrift

a*b*c [x](y) <tag> $5

" text = convert(Book(docs=[Doc("c.xhtml", body)])).chapter("001") assert "1\\. kein Listenpunkt" in text assert "\\# keine Überschrift" in text assert "a\\*b\\*c \\[x\\](y) \\ \\$5" in text def test_unknown_elements_are_reported_and_keep_html(convert): body = ("

U

Vor Inhalt bleibt" " nach.

") run = convert(Book(docs=[Doc("c.xhtml", body)])) assert "Vor Inhalt bleibt nach." in run.chapter("001") assert run.report["unsupported_elements"] == {"foo-widget": 1} kept = convert(Book(docs=[Doc("c.xhtml", body)]), "--keep-html") assert 'Inhalt bleibt' in kept.chapter("001") assert "evil" not in kept.chapter("001")