~shulhan/asciidoctor-go

ref: v0.1.0 asciidoctor-go/table_row.go -rw-r--r-- 706 bytes
4c1ded16Shulhan Release asciidoctor-go v0.1.0 (2021-03-06) 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package asciidoctor

import "bytes"

type tableRow struct {
	cells []*tableCell
	ncell int
}

func (row *tableRow) add(cell *tableCell) {
	row.cells = append(row.cells, cell)
	row.ncell++
	for x := 1; x < cell.format.ndupCol; x++ {
		row.cells = append(row.cells, cell)
		row.ncell++
	}
	if cell.format.nspanCol > 0 {
		row.ncell += (cell.format.nspanCol - 1)
	}
}

func (row *tableRow) String() string {
	var buf bytes.Buffer
	for _, cell := range row.cells {
		buf.WriteByte('|')
		buf.Write(cell.content)
	}
	return buf.String()
}