"""`html_text`: a host's description HTML as lines that keep its headings, bullets and paragraphs, and `excerpt` leaving those marks out of a row.""" from __future__ import annotations import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] if str(ROOT) not in sys.path: sys.path.insert(0, str(ROOT)) from app.models import excerpt # noqa: E402 from plugins.readers._shared import html_text # noqa: E402 def test_blocks_become_lines_lists_bullets_and_headings_marks() -> None: markup = ("

About

We are great.

" "

What you will do:

" "" "

Line one
Line two

") assert html_text(markup) == ("## About\nWe are great.\n## What you will do:\n" "• Build & ship\n• Lead\n• nested\n" "Line one\nLine two") def test_a_long_bold_paragraph_is_not_a_heading() -> None: loud = "

" + "Apply now " * 10 + "

" assert not html_text(loud).startswith("## ") def test_markup_escaped_once_more_is_read_as_markup() -> None: assert html_text("<p>Hello &amp; bye</p><ul><li>a</li></ul>") \ == "Hello & bye\n• a" def test_plain_text_keeps_its_lines_and_typed_bullets_become_bullets() -> None: assert html_text("plain text\n\n* one\n- two\nR&D < 5") == \ "plain text\n• one\n• two\nR&D < 5" def test_nothing_gives_nothing() -> None: assert html_text(None) == html_text("") == html_text("

") == "" def test_the_row_excerpt_leaves_the_marks_out() -> None: assert excerpt("## About the role\n• Build & run care.") == "About the role Build & run care."