Fix tests
Python CI / test (push) Failing after 5m26s

This commit is contained in:
2025-09-12 21:23:56 +02:00
parent 65ab46556f
commit 718027f3c8
12 changed files with 58 additions and 39 deletions
+1 -1
View File
@@ -317,7 +317,7 @@ class Document:
for heading in headings:
# Extract text from the heading
title = ""
for _, word in heading.words():
for _, word in heading.words_iter():
title += word.text + " "
title = title.strip()
+1 -1
View File
@@ -366,7 +366,7 @@ class Line(Box):
spacing_length = self._spacing[0] * (len(self._text_objects) - 1)
remaining=self._size[0] - word_length - spacing_length
fraction = remaining / text.width
spliter = round(fraction*len(text.text)) # get the split index for best spacing
spliter = max(1, round(fraction*len(word.text))) # get the split index for best spacing, use original word length
split = [Text(word.text[:spliter]+"-", word.style, self._draw, line=self, source=word), Text(word.text[spliter:], word.style, self._draw, line=self, source=word)]
self._text_objects.append(split[0])
word.add_concete(split)
+2 -2
View File
@@ -401,10 +401,10 @@ def extract_text_content(element: Tag, context: StyleContext) -> List[Word]:
if isinstance(child_result, list):
for block in child_result:
if isinstance(block, Paragraph):
for _, word in block.words():
for _, word in block.words_iter():
words.append(word)
elif isinstance(child_result, Paragraph):
for _, word in child_result.words():
for _, word in child_result.words_iter():
words.append(word)
return words
+2 -2
View File
@@ -124,7 +124,7 @@ class ChapterNavigator:
def _extract_heading_text(self, heading: Heading) -> str:
"""Extract text content from a heading block"""
words = []
for word in heading.words():
for position, word in heading.words_iter():
if isinstance(word, Word):
words.append(word.text)
return " ".join(words)
@@ -288,7 +288,7 @@ class BidirectionalLayouter:
# In practice, we'd need to handle each block type appropriately
if isinstance(block, Paragraph):
scaled_block = Paragraph(FontScaler.scale_font(block.style, font_scale))
for word in block.words():
for word in block.words_iter():
if isinstance(word, Word):
scaled_word = Word(word.text, FontScaler.scale_font(word.style, font_scale))
scaled_block.add_word(scaled_word)
+7 -1
View File
@@ -7,11 +7,17 @@ This module provides alignment-related functionality.
from enum import Enum
class Alignment(Enum):
"""Text alignment options"""
"""Text and box alignment options"""
# Horizontal alignment
LEFT = "left"
RIGHT = "right"
CENTER = "center"
JUSTIFY = "justify"
# Vertical alignment
TOP = "top"
MIDDLE = "middle"
BOTTOM = "bottom"
def __str__(self):
"""Return the string value of the alignment."""