Skip to content

An experimental Wikipedia/MediaWiki table parser and renderer.

Notifications You must be signed in to change notification settings

movsb/goldmark-wiki-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goldmark-wiki-table

An experimental Wikipedia/MediaWiki table parser and renderer written in golang.

Try it in your browser

Why?

The GitHub Flavored Markdown Table syntax sometimes cannot express complex tables, or tables with styles, or tables with colspans and rowspans. This parser/goldmark extension enables you depicting tables using Wiki Tables syntax.

How to use it in Goldmark?

import wikitable "github.com/movsb/goldmark-wiki-table"

md := goldmark.New(
	goldmark.WithExtensions(wikitable.New()),
)

See test/main.go for more details.

Examples

Write them directly in Markdown as paragraph, not in code blocks.

Note: Some styles may not be shown by GitHub.

minimal syntax

{|
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
OrangeApple
BreadPie
ButterIce cream

With styles

{| class="wikitable" style="color:green; background-color:#ffffcc;" cellpadding="10"
|Orange
|Apple
|-
|Bread
|Pie
|-
|Butter
|Ice cream
|}
OrangeApple
BreadPie
ButterIce cream

with spans

{| class="wikitable"
!colspan="6"|Shopping List
|-
|rowspan="2"|Bread & Butter
|Pie
|Buns
|Danish
|colspan="2"|Croissant
|-
|Cheese
|colspan="2"|Ice cream
|Butter
|Yogurt
|}
Shopping List
Bread & ButterPieBunsDanishCroissant
CheeseIce creamButterYogurt

with caption

{| class="wikitable"
|+ style="caption-side:bottom; color:#e76700;"|Food complements
|-
! style="color:green" | Fruits
! style="color:red" | Fats
|-
|Orange
|Butter
|-
|Pear
|Pie
|-
|Apple
|Ice cream
|}
Food complements
FruitsFats
OrangeButter
PearPie
AppleIce cream

Table in a table

{|
|+ An example table
|-
! First header
! colspan="2" | Second header
|-
| Upper left
| Upper middle
| rowspan="2" | Right side
|-
| Lower left
| Lower middle
|-
| colspan="3"| Text before a nested table...
{|
|+ A table in a table
| AAA
| BBB
|}
|}
An example table
First headerSecond header
Upper leftUpper middleRight side
Lower leftLower middle
Text before a nested table... A table in a table
AAABBB

References

License

MIT

About

An experimental Wikipedia/MediaWiki table parser and renderer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages