summaryrefslogtreecommitdiffstats
path: root/content.go
diff options
context:
space:
mode:
Diffstat (limited to 'content.go')
-rw-r--r--content.go42
1 files changed, 6 insertions, 36 deletions
diff --git a/content.go b/content.go
index 6a728f5..dbe0fa4 100644
--- a/content.go
+++ b/content.go
@@ -28,6 +28,9 @@ type ContainerBlock interface {
// Children returns the child blocks.
Children() []Block
+
+ // AppendChild adds a new child block to the end of the list of children.
+ AppendChild(Block)
}
// ContentBlock represents a block that holds other content blocks.
@@ -467,45 +470,12 @@ func parseContentList(p *Parser, block *TokenBlock) (*ListBlock, error) {
// TableBlock represents a "table" content block.
type TableBlock struct {
- rows []Block
+ ContentBlock
}
// NewTableBlock creates a new TableBlock.
func NewTableBlock() *TableBlock {
- return &TableBlock{}
-}
-
-// Name returns the block name "table".
-func (t *TableBlock) Name() string {
- return "table"
-}
-
-// Args returns the block's nil arguments.
-func (t *TableBlock) Args() []string {
- return nil
-}
-
-// WriteIndent writes the table header and contents indented by n tabs.
-func (t *TableBlock) WriteIndent(w io.Writer, n int) error {
- if err := WriteIndent(w, t.Name(), n); err != nil {
- return err
- }
- for _, row := range t.rows {
- if err := row.WriteIndent(w, n+1); err != nil {
- return err
- }
- }
- return nil
-}
-
-// Children returns the table's rows.
-func (t *TableBlock) Children() []Block {
- return t.rows
-}
-
-// AppendRow adds a new row to the end of the table.
-func (t *TableBlock) AppendRow(row Block) {
- t.rows = append(t.rows, row)
+ return &TableBlock{*NewContentBlock("table", "")}
}
func (t *TableBlock) parse(p *Parser, block *TokenBlock) (err error) {
@@ -526,7 +496,7 @@ func (t *TableBlock) parse(p *Parser, block *TokenBlock) (err error) {
err = parseUnknown(p, blk)
}
if b != nil {
- t.AppendRow(b)
+ t.AppendChild(b)
}
} else if err = p.Next(); err != nil {
break