r""" Visitor for (alignment point marker) MathML elements. The element is an empty element used within table cells () to mark specific alignment points for fine-grained horizontal alignment control. It differs from in that it marks a specific point within content rather than grouping alignment zones. In LaTeX conversion, alignment points are handled implicitly by the array/matrix environment's column specifications and & separators. Therefore, malignmark markers are treated as transparent (no output). """ from lxml import etree as ET from ..core.interfaces import Visitor, Strategy from ..utils import local_name as _local class MalignmarkVisitor(Visitor): r""" Handles (alignment point marker) MathML elements. Treats malignmark as an invisible marker since LaTeX handles alignment through column specifications and & separators in array/matrix environments. The element is completely ignored in conversion. Examples: Alignment point in cell: x = 5 → x = 5 (malignmark ignored) Multiple alignment marks: a b → a b (both malignmark markers ignored) Mark with edge attribute: → (empty - no output) Note: LaTeX doesn't support MathML's alignment mark concept. Alignment is controlled by column specifications in the array/matrix preamble (e.g., {ccc} for center-aligned, {lll} for left-aligned) and by & separators between cells. Therefore, malignmark elements produce no output. """ def __init__(self, strategy: Strategy): """Initialize the Malignmark visitor.""" super().__init__(strategy) def visit(self, node: ET.Element) -> str: r""" Convert element (returns empty string). Args: node: The element to convert Returns: Empty string (malignmark is invisible in LaTeX) Raises: ValueError: If node is not a element """ if not self.can_handle(node): raise ValueError(f"MalignmarkVisitor cannot handle element '{node.tag}'") # Malignmark is an invisible alignment point marker - no output return "" def can_handle(self, node: ET.Element) -> bool: """Check if this visitor can handle the given node.""" return _local(node.tag) == 'malignmark' @property def element_name(self) -> str: """Get the element name this visitor handles.""" return 'malignmark' def __repr__(self) -> str: """String representation for debugging.""" return f"MalignmarkVisitor(strategy={self.strategy.name})"