@@ -13,7 +13,10 @@ from md2gost.word_fix import (
|
||||
continuation_label,
|
||||
find_page_break_row,
|
||||
fix_continuations,
|
||||
is_caption_orphaned,
|
||||
is_orphan_header_break,
|
||||
parse_caption_text,
|
||||
split_vmerge_spans_at_break,
|
||||
)
|
||||
|
||||
|
||||
@@ -54,6 +57,33 @@ def test_find_page_break_row():
|
||||
assert find_page_break_row([1, 1, 2, 2]) == 3
|
||||
assert find_page_break_row([2, 2, 3]) == 3
|
||||
assert find_page_break_row([1, 2]) == 2
|
||||
# typical vMerge table pages after cell-based detection
|
||||
assert find_page_break_row([14, 14, 14, 14, 14, 14, 15, 15]) == 7
|
||||
|
||||
|
||||
def test_orphan_header_and_caption_guards():
|
||||
"""Method guide: no title-only / title+column-headers alone at page end."""
|
||||
# Split would leave only heading row on previous page
|
||||
assert is_orphan_header_break(2, had_header=True) is True
|
||||
assert is_orphan_header_break(2, had_header=False) is False
|
||||
assert is_orphan_header_break(3, had_header=True) is False
|
||||
assert is_orphan_header_break(None, had_header=True) is False
|
||||
# Caption on earlier page than first table row
|
||||
assert is_caption_orphaned(5, 6) is True
|
||||
assert is_caption_orphaned(5, 5) is False
|
||||
assert is_caption_orphaned(None, 6) is False
|
||||
|
||||
|
||||
def test_split_vmerge_spans_at_break():
|
||||
# (row, col, span, text) — merge rows 2..6 (span 5), break at row 7 → all in first
|
||||
spans = [(2, 1, 5, "A"), (7, 1, 2, "B")]
|
||||
first, cont = split_vmerge_spans_at_break(spans, 7)
|
||||
assert first == [(2, 1, 5, "A")]
|
||||
assert cont == [(1, 1, 2, "B")]
|
||||
# merge crosses break: rows 5..8, break at 7
|
||||
first, cont = split_vmerge_spans_at_break([(5, 1, 4, "X")], 7)
|
||||
assert first == [(5, 1, 2, "X")]
|
||||
assert cont == [(1, 1, 2, "X")]
|
||||
|
||||
|
||||
def test_continuation_label():
|
||||
|
||||
Reference in New Issue
Block a user