Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

mdtable source pure

Package mdtable provides a simple way to create Markdown tables.

Overview

Package mdtable provides a simple way to create Markdown tables.

Example usage:

Example
 1import "gno.land/p/moul/mdtable"
 2
 3func Render(path string) string {
 4    table := mdtable.Table{
 5        Headers: []string{"ID", "Title", "Status", "Date"},
 6    }
 7    table.Append([]string{"#1", "Add a new validator", "succeed", "2024-01-01"})
 8    table.Append([]string{"#2", "Change parameter", "timed out", "2024-01-02"})
 9    return table.String()
10}

Output:

Example
1| ID | Title | Status | Date |
2| --- | --- | --- | --- |
3| #1 | Add a new validator | succeed | 2024-01-01 |
4| #2 | Change parameter | timed out | 2024-01-02 |

Types 1

type Table

struct
1type Table struct {
2	Headers []string
3	Rows    [][]string
4}
source

Methods on Table

func Append

method on Table
1func (t *Table) Append(row []string)
source

func String

method on Table
1func (t Table) String() string
source

Imports 1

  • strings stdlib

Source Files 3