r""" Visitor for (alignment group marker) MathML elements. The element is an empty element used within table cells () to mark alignment groups. It's used to control horizontal alignment across table columns for complex multi-line expressions. In LaTeX conversion, alignment groups are handled implicitly by the array/matrix environment's column specifications (e.g., {lll} for left-aligned columns). Therefore, maligngroup 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 MaligngroupVisitor(Visitor): r""" Handles (alignment group marker) MathML elements. Treats maligngroup as an invisible marker since LaTeX handles alignment through column specifications in array/matrix environments. The element is completely ignored in conversion. Examples: Alignment group in cell: x → x (maligngroup ignored) Multiple alignment groups: a b → a b (both maligngroup markers ignored) Group with alignment attribute: → (empty - no output) Note: LaTeX doesn't support MathML's alignment group concept. Alignment is controlled by column specifications in the array/matrix preamble (e.g., {ccc} for center-aligned, {lll} for left-aligned). Therefore, maligngroup elements produce no output. """ def __init__(self, strategy: Strategy): """Initialize the Maligngroup 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 (maligngroup is invisible in LaTeX) Raises: ValueError: If node is not a element """ if not self.can_handle(node): raise ValueError(f"MaligngroupVisitor cannot handle element '{node.tag}'") # Maligngroup is an invisible alignment 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) == 'maligngroup' @property def element_name(self) -> str: """Get the element name this visitor handles.""" return 'maligngroup' def __repr__(self) -> str: """String representation for debugging.""" return f"MaligngroupVisitor(strategy={self.strategy.name})"