[ADD] подписи листингов по ГОСТ и читаемый кегль кода
This commit is contained in:
@@ -309,3 +309,59 @@ def test_ptp_task_has_no_hardcoded_assignment_text() -> None:
|
||||
source = inspect.getsource(ptp_task)
|
||||
for forbidden in ("Web", "2D-игра", "GitFlic", "Javascript", "Посевин", "Коновалов"):
|
||||
assert forbidden not in source
|
||||
|
||||
|
||||
LISTING_MD = (
|
||||
"Листинг 1 —— Потокобезопасная очередь\n\n"
|
||||
"```cpp\n"
|
||||
"template <typename T>\n"
|
||||
"class ThreadSafeQueue {};\n"
|
||||
"```\n"
|
||||
)
|
||||
|
||||
|
||||
def test_listing_with_caption() -> None:
|
||||
tex = render(LISTING_MD)
|
||||
assert "caption={Потокобезопасная очередь}" in tex
|
||||
assert "language=C++" in tex
|
||||
assert "class ThreadSafeQueue {};" in tex
|
||||
|
||||
|
||||
def test_listing_caption_number_is_discarded() -> None:
|
||||
tex = render(LISTING_MD)
|
||||
assert "Листинг 1" not in tex
|
||||
|
||||
|
||||
def test_listing_caption_paragraph_is_not_duplicated() -> None:
|
||||
tex = render(LISTING_MD)
|
||||
assert tex.count("Потокобезопасная очередь") == 1
|
||||
|
||||
|
||||
def test_listing_without_caption_stays_bare() -> None:
|
||||
tex = render("```cpp\nint main() {}\n```\n")
|
||||
assert "\\begin{lstlisting}[language=C++]" in tex
|
||||
assert "caption=" not in tex
|
||||
|
||||
|
||||
def test_listing_caption_without_language() -> None:
|
||||
tex = render("Листинг 2 —— Формат строки\n\n```\nid,freq,power\n```\n")
|
||||
assert "caption={Формат строки}" in tex
|
||||
assert "language=" not in tex
|
||||
|
||||
|
||||
def test_paragraph_starting_with_listing_word_is_not_a_caption() -> None:
|
||||
tex = render("Листинг приведён ниже.\n\n```cpp\nint x;\n```\n")
|
||||
assert "caption=" not in tex
|
||||
assert "Листинг приведён ниже." in tex
|
||||
|
||||
|
||||
def test_listing_language_is_mapped_to_listings_name() -> None:
|
||||
"""listings не знает 'cpp', только 'C++'."""
|
||||
tex = render("```cpp\nint x;\n```\n")
|
||||
assert "language=C++" in tex
|
||||
|
||||
|
||||
def test_listing_unsupported_language_falls_back_to_plain() -> None:
|
||||
tex = render("```yaml\nkey: value\n```\n")
|
||||
assert "language=" not in tex
|
||||
assert "key: value" in tex
|
||||
|
||||
Reference in New Issue
Block a user