An open API service indexing awesome lists of open source software.

https://github.com/jiro4989/markup-table

A package for generating tables of markup languages in Go.
https://github.com/jiro4989/markup-table

golang library markup package

Last synced: 8 days ago
JSON representation

A package for generating tables of markup languages in Go.

Awesome Lists containing this project

README

          

# markup-table

[![Build Status](https://travis-ci.org/jiro4989/markup-table.svg?branch=master)](https://travis-ci.org/jiro4989/markup-table)

`markup-table` is a package for generating tables of markup languages.

## Installation

```bash
go get github.com/jiro4989/markup-table
```

## Usage examples

```go
package table_test

import (
"fmt"

table "github.com/jiro4989/markup-table"
)

func ExampleMarkdown() {
matrix := [][]string{

{"Head 1", "Head 2", "Head 3"},
{"Body 1", "Body 2", "Body 3"},
{"Body 4", "Body 5", "Body 6"},
}
for _, row := range table.Markdown(matrix) {
fmt.Println(row)
}
// Output:
// | Head 1 | Head 2 | Head 3 |
// | :---: | :---: | :---: |
// | Body 1 | Body 2 | Body 3 |
// | Body 4 | Body 5 | Body 6 |
}

func ExampleHTML() {
matrix := [][]string{

{"Head 1", "Head 2", "Head 3"},
{"Body 1", "Body 2", "Body 3"},
{"Body 4", "Body 5", "Body 6"},
}
for _, row := range table.HTML(matrix) {
fmt.Println(row)
}
// Output:
// ,
// ,
// Head 1Head 2Head 3,
// ,
// ,
// Body 1Body 2Body 3,
// Body 4Body 5Body 6,
// ,
// ,
}

func ExampleAsciidoc() {
matrix := [][]string{

{"Head 1", "Head 2", "Head 3"},
{"Body 1", "Body 2", "Body 3"},
{"Body 4", "Body 5", "Body 6"},
}
for _, row := range table.Asciidoc(matrix) {
fmt.Println(row)
}
// Output:
// [options=header],
// |=================,
// | Head 1 | Head 2 | Head 3,
// | Body 1 | Body 2 | Body 3,
// | Body 4 | Body 5 | Body 6,
// |=================,
}
```

## Documentations

* [markup-table - godoc](https://godoc.org/github.com/jiro4989/markup-table)