mdtable

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package mdtable writes tables as markdown. DOCX, PPTX, XLSX and HTML each describe a table differently, merged cells above all; their readers build a Table and RenderMarkdown writes it, so a table looks the same whatever file it came from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromSpanRows

func FromSpanRows(rows [][]SpanCell) [][]string

FromSpanRows resolves rows of cells with ColSpan/RowSpan (the HTML model: a spanned cell is written once and the positions it covers are left out of the later rows) into a Table.

Types

type SpanCell

type SpanCell struct {
	Text    string
	ColSpan int
	RowSpan int
}

SpanCell is a cell as a file declares it, before merges are resolved.

type Table

type Table struct {
	Caption    string
	Rows       [][]string
	HeaderRows int // how many leading rows are header rows; 0 when the file does not say
}

Table is a table once its merged cells have been resolved: every row has one string per column, and a cell that spans several rows or columns has its text in each of the positions it covers. Markdown has no merged cells, and a row that is missing the value its neighbour spans stops making sense once a table is cut into chunks, so each row carries all of its own values.

func (Table) RenderMarkdown

func (t Table) RenderMarkdown(sb *strings.Builder)

RenderMarkdown writes the table as a GitHub-flavored markdown table. Rows and columns with nothing in them (spacers) are dropped; several header rows become one, each column's parts joined with " / "; a table with one column is a list in disguise (a layout table, a boxed paragraph) and is written as lines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL