Skip to content

Tables: Implement per-cell alignment and style specifiers #315

@nlopes

Description

@nlopes

Problem

The full AsciiDoc cell specifier syntax supports per-cell alignment and style overrides, not just spans.

AsciiDoc syntax

|===
| Normal | ^| Centered | >| Right-aligned
| Default | .^| Vertically centered | e| Emphasis style
| 2+^.>m| Colspan 2, center, bottom, monospace
|===

Cell specifier format: [colspan][.rowspan]+[halign][.valign][style]|

Where:

  • halign: < (left), ^ (center), > (right)
  • valign: .< (top), .^ (middle), .> (bottom)
  • style: a (asciidoc), d (default), e (emphasis), h (header), l (literal), m (monospace), s (strong)

Current behavior

Only span specifiers (2+, .3+, 2.3+) are parsed. Alignment and style modifiers are treated as cell content.

Implementation requirements

1. Parser changes (acdc-parser/src/blocks/table.rs)

Extend CellSpecifier to include:

pub struct CellSpecifier {
    pub colspan: usize,
    pub rowspan: usize,
    pub halign: Option<HorizontalAlignment>,  // NEW
    pub valign: Option<VerticalAlignment>,    // NEW
    pub style: Option<ColumnStyle>,           // NEW
}

2. AST changes (acdc-parser/src/model/tables.rs)

Add optional per-cell formatting to TableColumn:

pub struct TableColumn {
    pub content: Vec<Block>,
    pub colspan: usize,
    pub rowspan: usize,
    pub halign: Option<HorizontalAlignment>,  // NEW: overrides column default
    pub valign: Option<VerticalAlignment>,    // NEW: overrides column default
    pub style: Option<ColumnStyle>,           // NEW: overrides column default
}

3. HTML renderer (converters/html/src/table.rs)

Use per-cell alignment/style if specified, otherwise fall back to column defaults.

Priority

Low - column-level alignment works for most use cases. Per-cell overrides are less common.

References

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions