mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
commit
3190eb8348
2 changed files with 4 additions and 19 deletions
|
|
@ -48,10 +48,8 @@ func (b *tableParagraphTransformer) Transform(node *gast.Paragraph, reader text.
|
||||||
table := ast.NewTable()
|
table := ast.NewTable()
|
||||||
table.Alignments = alignments
|
table.Alignments = alignments
|
||||||
table.AppendChild(table, ast.NewTableHeader(header))
|
table.AppendChild(table, ast.NewTableHeader(header))
|
||||||
if lines.Len() > 2 {
|
for i := 2; i < lines.Len(); i++ {
|
||||||
for i := 2; i < lines.Len(); i++ {
|
table.AppendChild(table, b.parseRow(lines.At(i), alignments, false, reader))
|
||||||
table.AppendChild(table, b.parseRow(lines.At(i), alignments, false, reader))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
node.Parent().InsertBefore(node.Parent(), node, table)
|
node.Parent().InsertBefore(node.Parent(), node, table)
|
||||||
node.Parent().RemoveChild(node.Parent(), node)
|
node.Parent().RemoveChild(node.Parent(), node)
|
||||||
|
|
@ -116,24 +114,12 @@ func (b *tableParagraphTransformer) parseDelimiter(segment text.Segment, reader
|
||||||
var alignments []ast.Alignment
|
var alignments []ast.Alignment
|
||||||
for _, col := range cols {
|
for _, col := range cols {
|
||||||
if tableDelimLeft.Match(col) {
|
if tableDelimLeft.Match(col) {
|
||||||
if alignments == nil {
|
|
||||||
alignments = []ast.Alignment{}
|
|
||||||
}
|
|
||||||
alignments = append(alignments, ast.AlignLeft)
|
alignments = append(alignments, ast.AlignLeft)
|
||||||
} else if tableDelimRight.Match(col) {
|
} else if tableDelimRight.Match(col) {
|
||||||
if alignments == nil {
|
|
||||||
alignments = []ast.Alignment{}
|
|
||||||
}
|
|
||||||
alignments = append(alignments, ast.AlignRight)
|
alignments = append(alignments, ast.AlignRight)
|
||||||
} else if tableDelimCenter.Match(col) {
|
} else if tableDelimCenter.Match(col) {
|
||||||
if alignments == nil {
|
|
||||||
alignments = []ast.Alignment{}
|
|
||||||
}
|
|
||||||
alignments = append(alignments, ast.AlignCenter)
|
alignments = append(alignments, ast.AlignCenter)
|
||||||
} else if tableDelimNone.Match(col) {
|
} else if tableDelimNone.Match(col) {
|
||||||
if alignments == nil {
|
|
||||||
alignments = []ast.Alignment{}
|
|
||||||
}
|
|
||||||
alignments = append(alignments, ast.AlignNone)
|
alignments = append(alignments, ast.AlignNone)
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,9 @@ func ReadWhile(source []byte, index [2]int, pred func(byte) bool) (int, bool) {
|
||||||
// IsBlank returns true if the given string is all space characters.
|
// IsBlank returns true if the given string is all space characters.
|
||||||
func IsBlank(bs []byte) bool {
|
func IsBlank(bs []byte) bool {
|
||||||
for _, b := range bs {
|
for _, b := range bs {
|
||||||
if IsSpace(b) {
|
if !IsSpace(b) {
|
||||||
continue
|
return false
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue