diff --git a/browser/layouts/BlockLayout.py b/browser/layouts/BlockLayout.py index 5a9c716..6ee6137 100644 --- a/browser/layouts/BlockLayout.py +++ b/browser/layouts/BlockLayout.py @@ -7,6 +7,7 @@ from browser.utils.logging import log from web.dom.elements.Element import Element from browser.styling.utils import style +from web.dom.elements.Text import Text class BlockLayout(Layout): def __init__(self, node: Element, parent: Layout, previous: Layout): diff --git a/browser/layouts/InlineLayout.py b/browser/layouts/InlineLayout.py index 2e39e64..e741ea3 100644 --- a/browser/layouts/InlineLayout.py +++ b/browser/layouts/InlineLayout.py @@ -157,7 +157,8 @@ def text(self, element: Text) -> None: if style == "normal": style = "roman" size = int(float(element.style["font-size"][:-2]) * .75) font = get_font(size, font_weight_to_string(weight), style) - for word in element.data.split(): + data = element.data.strip() + for word in data.split(): w = font.measure(word) if self.parent.float == "none": if self.cursor_x + w > self.width - globals.HSTEP: diff --git a/browser/layouts/Layout.py b/browser/layouts/Layout.py index 869667f..912dfcf 100644 --- a/browser/layouts/Layout.py +++ b/browser/layouts/Layout.py @@ -203,10 +203,6 @@ def layout_mode(self, node: Node) -> Literal["inline", "block"]: if isinstance(child, Text): continue if child.name in BLOCK_ELEMENTS: mode = "block" - - style_mode = node.style.get("display") - if style_mode in ["inline", "block"]: - mode = style_mode return mode else: return "block"