added markdown table support for go port
This commit is contained in:
@@ -1482,6 +1482,43 @@ func TestRenderMDBlocks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderTableFormatting(t *testing.T) {
|
||||
COL = true
|
||||
defer func() { COL = false }()
|
||||
|
||||
raw := strings.Join([]string{
|
||||
"| Name | Role | Location |",
|
||||
"| :--- | :---: | ---: |",
|
||||
"| Alice | `Lead` | New York |",
|
||||
"| Bob | Developer | London |",
|
||||
}, "\n")
|
||||
|
||||
rendered := renderMD(raw)
|
||||
lines := strings.Split(rendered, "\n")
|
||||
if len(lines) != 6 {
|
||||
t.Fatalf("expected 6 table lines (top, header, mid, row1, row2, bot), got %d:\n%s", len(lines), rendered)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(lines[0], "\033[2m┌") || !strings.HasSuffix(lines[0], "┐\033[0m") {
|
||||
t.Errorf("top border = %q", lines[0])
|
||||
}
|
||||
if !strings.Contains(lines[1], "Name") || !strings.Contains(lines[1], "Role") || !strings.Contains(lines[1], "Location") {
|
||||
t.Errorf("header row = %q", lines[1])
|
||||
}
|
||||
if !strings.HasPrefix(lines[2], "\033[2m├") || !strings.HasSuffix(lines[2], "┤\033[0m") {
|
||||
t.Errorf("mid border = %q", lines[2])
|
||||
}
|
||||
if !strings.Contains(lines[3], "Alice") || !strings.Contains(lines[3], "New York") {
|
||||
t.Errorf("row 1 = %q", lines[3])
|
||||
}
|
||||
if !strings.Contains(lines[4], "Bob") || !strings.Contains(lines[4], "London") {
|
||||
t.Errorf("row 2 = %q", lines[4])
|
||||
}
|
||||
if !strings.HasPrefix(lines[5], "\033[2m└") || !strings.HasSuffix(lines[5], "┘\033[0m") {
|
||||
t.Errorf("bot border = %q", lines[5])
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderMDNoColorFallback(t *testing.T) {
|
||||
COL = false
|
||||
raw := "# Heading\n**bold** and `code`\n- list item"
|
||||
@@ -1492,3 +1529,4 @@ func TestRenderMDNoColorFallback(t *testing.T) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user