CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-neoteroi-mkdocs

Plugins for MkDocs and Python Markdown providing OpenAPI documentation, contributor tracking, timelines, cards, advanced tables, and project management features.

Pending
Overview
Eval results
Files

advanced-tables.mddocs/

Advanced Tables

Tables with colspan and rowspan support using standard Markdown table syntax with cell-spanning notation. This Markdown extension provides enhanced table functionality, allowing cells to span multiple columns and rows while maintaining compatibility with standard Markdown table syntax.

Capabilities

Extension Configuration

Configure the advanced tables extension for enhanced table processing.

class SpanTableExtension(Extension):
    """
    Markdown extension for tables with colspan and rowspan support.
    """
    def extendMarkdown(self, md):
        """
        Registers the span table processor with the Markdown parser.
        
        Parameters:
        - md: Markdown parser instance
        """

def make_extension(*args, **kwargs):
    """
    Factory function for creating SpanTableExtension instances.
    
    Returns:
    SpanTableExtension: Configured extension instance
    """

Table Processing

The extension processes ::spantable:: blocks to create advanced tables.

class SpanTableProcessor(BlockProcessor):
    """
    Block processor for span tables with advanced cell spanning.
    """
    START_RE: Pattern  # Compiled regex for ::spantable::
    END_RE: Pattern    # Compiled regex for ::end-spantable::
    
    def test(self, parent, block):
        """
        Tests if block contains span table syntax.
        
        Parameters:
        - parent: Parent XML element
        - block: Markdown block to test
        
        Returns:
        bool: True if block matches span table pattern
        """
    
    def run(self, parent, blocks):
        """
        Processes span table blocks and generates HTML.
        
        Parameters:
        - parent: Parent XML element
        - blocks: List of Markdown blocks
        """
    
    def find_closing_fragment_index(self, blocks) -> int:
        """
        Finds the index of the closing ::end-spantable:: tag.
        
        Parameters:
        - blocks: List of Markdown blocks
        
        Returns:
        int: Index of closing tag, -1 if not found
        """
    
    def read_first_table(self, blocks) -> Optional[SpanTable]:
        """
        Extracts the first table from the given blocks.
        
        Parameters:
        - blocks: List of Markdown blocks
        
        Returns:
        Optional[SpanTable]: Parsed table or None
        """

Data Models

Table Data Structures

class Cell:
    """
    Represents a table cell with spanning capabilities.
    
    Attributes:
    - text: Cell text content
    - skip: Whether to skip rendering (used for spanned cells)
    - col_span: Number of columns to span
    - row_span: Number of rows to span
    - col_span_defined: Whether colspan was explicitly set
    - row_span_defined: Whether rowspan was explicitly set
    - props: Additional HTML properties
    """
    text: str
    skip: bool
    col_span: int
    row_span: int
    col_span_defined: bool
    row_span_defined: bool
    props: Optional[Dict[str, str]]
    
    @property
    def html_class(self) -> str:
        """
        Returns CSS class string for the cell.
        
        Returns:
        str: Space-separated CSS class names
        """

class SpanTable(Table):
    """
    Table with colspan and rowspan support.
    
    Attributes:
    - matrix: Table matrix structure with Cell objects
    """
    matrix: Matrix

class Matrix:
    """
    Represents table structure as a matrix of cells.
    
    Attributes:
    - rows: Tuple of row lists containing Cell objects
    """
    rows: Tuple[List[Any], ...]
    
    def __setitem__(self, key, value): ...
    def __getitem__(self, key): ...
    def __iter__(self): ...

class Table:
    """
    Base table class with headers and records.
    
    Attributes:
    - headers: Table column headers
    - records: Table data records
    """
    headers: Tuple[str, ...]
    records: Tuple[Tuple[str, ...], ...]
    
    def items(self): ...
    def __iter__(self): ...
    def __len__(self): ...
    def __getitem__(self, index): ...

Table Parsing

def read_table(markdown: str, cls=Table):
    """
    Parses Markdown table syntax into Table objects.
    
    Parameters:
    - markdown: Markdown table content
    - cls: Table class to instantiate (default: Table)
    
    Returns:
    Table instance or None if no valid table found
    """

Usage Examples

Basic Span Table

Use ::spantable:: blocks with standard Markdown table syntax:

::spantable::
| Name    | Age | Location     |
|---------|-----|--------------|
| John    | 25  | New York     |
| Jane    | 30  | Los Angeles  |
| Bob     | 35  | Chicago      |
::end-spantable::

Tables with Column Spanning

Use || to span cells across columns:

::spantable::
| Product | Q1 | Q2 | Q3 | Q4 |
|---------|----|----|----|----|
| A       | 10 | 20 | 15 | 25 |
| B       | 30 | Total: 90 ||
| C       | 40 | 35 | 30 | 20 |
::end-spantable::

Tables with Row Spanning

Use row spanning notation for cells that span multiple rows:

::spantable::
| Category | Item      | Price |
|----------|-----------|-------|
| Food ^   | Apple     | $1.00 |
|          | Banana    | $0.50 |
|          | Orange    | $0.75 |
| Drinks ^ | Water     | $1.50 |
|          | Soda      | $2.00 |
::end-spantable::

Complex Table with Both Spanning Types

::spantable:: caption="Sales Report" class="sales-table"
| Region  | Q1    | Q2    | Q3    | Q4    | Total |
|---------|-------|-------|-------|-------|-------|
| North ^ | Jan   | 100   | 150   | 200   | 450   |
|         | Feb   | 110   | 160   | 210   |       |
|         | Mar   | 120   | 170   | 220   |       |
| South   | 300   | Summary ||||| 800   |
| West    | 250   | 280   | 290   | 300   | 1120  |
| Total   | 1050  | Grand Total |||||| 2370  |
::end-spantable::

Table with Custom Properties

::spantable:: class="data-table" caption="Quarterly Results"
| Metric      | Value    | Change |
|-------------|----------|--------|
| Revenue     | $1.2M    | +15%   |
| Profit      | $300K    | +22%   |
| Growth Rate | Combined ||       |
::end-spantable::

Table with Cell Classes

Cells can have individual CSS classes:

::spantable::
| Status  | Count | Percentage |
|---------|-------|------------|
| Active  | 150   | 75%        |
| Pending | 30    | 15%        |
| Error   | 20    | 10%        |
::end-spantable::

Cell Spanning Syntax

Column Spanning

  • Single empty cell: | - Normal cell boundary
  • Column span: || - Cell spans to the next column
  • Multiple column span: ||| - Cell spans multiple columns

Row Spanning

  • Row span marker: ^ - Indicates the cell above spans down
  • Cell content with row span: Cell content followed by ^

Combining Spans

::spantable::
| A  | B spanning 2 cols || D |
| E^ | F                 | G | H |
|    | I                 | J | K |
::end-spantable::

This creates:

  • Cell A spans 2 rows
  • Cell B spans 2 columns
  • Cell F is a regular cell
  • Proper alignment maintained

Table Properties

Supported Properties

::spantable:: caption="Table Title" class="custom-class" id="table-id"

Available properties:

  • caption: Table caption text
  • class: Additional CSS classes
  • id: HTML ID attribute

Generated HTML Structure

<div class="span-table-wrapper">
  <table class="span-table custom-class" id="table-id">
    <caption>Table Title</caption>
    <tr>
      <td colspan="2">Spanning Cell</td>
      <td rowspan="2">Row Spanning Cell</td>
    </tr>
    <tr>
      <td>Regular Cell</td>
      <td>Another Cell</td>
    </tr>
  </table>
</div>

Styling and Customization

Default CSS Classes

  • .span-table-wrapper: Container wrapper
  • .span-table: Table element
  • Custom classes can be added via the class property

Cell Alignment

Standard Markdown alignment syntax is supported:

::spantable::
| Left | Center | Right |
|:-----|:------:|------:|
| A    | B      | C     |
::end-spantable::

Responsive Tables

The wrapper div allows for responsive table styling:

.span-table-wrapper {
  overflow-x: auto;
}

.span-table {
  min-width: 100%;
  border-collapse: collapse;
}

Install with Tessl CLI

npx tessl i tessl/pypi-neoteroi-mkdocs

docs

advanced-tables.md

card-layouts.md

contributors-tracking.md

index.md

openapi-documentation.md

project-management.md

timeline-visualization.md

tile.json