Loading generateBaseline/htmlToGridTable.py +41 Changes for generateBaseline/htmlToGridTable.py: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -378,6 +378,47 @@ def _generateGridSubTable(table: list[list[_HtmlCell]], maxCols: int, colWidths: lines.append(_createSeparator(colWidths, maxCols, '-', colAlignments=lastAlign)) return '\n'.join(lines) def generateGridTableFromRows(headerRows: list[list[_HtmlCell]], bodyRows: list[list[_HtmlCell]]) -> str: """Assemble a Pandoc grid table from parsed header/body cell rows.""" if not headerRows and not bodyRows: return '' allRows = headerRows + bodyRows maxCols = max((cell.col + cell.colspan for row in allRows for cell in row), default=0) if maxCols == 0: return '' colWidths = [1] * maxCols if headerRows: _updateColWidths(headerRows, maxCols, colWidths) if bodyRows: _updateColWidths(bodyRows, maxCols, colWidths) colAlignments = _deriveColumnAlignments(headerRows, bodyRows, maxCols) headerGridTable = ( _generateGridSubTable(headerRows, maxCols, colWidths, colAlignments, 'last') if headerRows else '' ) bodyAlignmentOn = 'first' if not headerRows else None bodyGridTable = ( _generateGridSubTable(bodyRows, maxCols, colWidths, colAlignments, bodyAlignmentOn) if bodyRows else '' ) if headerGridTable: headerLines = headerGridTable.split('\n') headerLines[-1] = headerLines[-1].replace('-', '=') bodyLines = bodyGridTable.split('\n') if bodyGridTable else [] if bodyLines: bodyLines = bodyLines[1:] # drop body's top border if bodyLines: return '\n'.join(headerLines) + '\n' + '\n'.join(bodyLines) return '\n'.join(headerLines) return bodyGridTable def generateGridTableFromHtml(htmlContent: str) -> str: """Generate a Pandoc-style grid table from an HTML table string. Loading Loading
generateBaseline/htmlToGridTable.py +41 Changes for generateBaseline/htmlToGridTable.py: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -378,6 +378,47 @@ def _generateGridSubTable(table: list[list[_HtmlCell]], maxCols: int, colWidths: lines.append(_createSeparator(colWidths, maxCols, '-', colAlignments=lastAlign)) return '\n'.join(lines) def generateGridTableFromRows(headerRows: list[list[_HtmlCell]], bodyRows: list[list[_HtmlCell]]) -> str: """Assemble a Pandoc grid table from parsed header/body cell rows.""" if not headerRows and not bodyRows: return '' allRows = headerRows + bodyRows maxCols = max((cell.col + cell.colspan for row in allRows for cell in row), default=0) if maxCols == 0: return '' colWidths = [1] * maxCols if headerRows: _updateColWidths(headerRows, maxCols, colWidths) if bodyRows: _updateColWidths(bodyRows, maxCols, colWidths) colAlignments = _deriveColumnAlignments(headerRows, bodyRows, maxCols) headerGridTable = ( _generateGridSubTable(headerRows, maxCols, colWidths, colAlignments, 'last') if headerRows else '' ) bodyAlignmentOn = 'first' if not headerRows else None bodyGridTable = ( _generateGridSubTable(bodyRows, maxCols, colWidths, colAlignments, bodyAlignmentOn) if bodyRows else '' ) if headerGridTable: headerLines = headerGridTable.split('\n') headerLines[-1] = headerLines[-1].replace('-', '=') bodyLines = bodyGridTable.split('\n') if bodyGridTable else [] if bodyLines: bodyLines = bodyLines[1:] # drop body's top border if bodyLines: return '\n'.join(headerLines) + '\n' + '\n'.join(bodyLines) return '\n'.join(headerLines) return bodyGridTable def generateGridTableFromHtml(htmlContent: str) -> str: """Generate a Pandoc-style grid table from an HTML table string. Loading