forked from yosssi/ace
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplain_text_inner.go
More file actions
44 lines (34 loc) · 888 Bytes
/
plain_text_inner.go
File metadata and controls
44 lines (34 loc) · 888 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
package ace
import "io"
// HTML
const (
htmlBr = "<br>"
)
// plainTextInner represents a plain text inner.
type plainTextInner struct {
elementBase
insertBr bool
}
// WriteTo writes data to w.
func (e *plainTextInner) WriteTo(w io.Writer) (int64, error) {
s := ""
if (e.parent.Base().ln.indent+1)*2 <= len(e.ln.str) {
s = e.ln.str[(e.parent.Base().ln.indent+1)*2:]
}
if e.insertBr && !e.lastChild {
s += htmlBr
}
i, err := w.Write([]byte(s + lf))
return int64(i), err
}
// CanHaveChildren returns false.
func (e *plainTextInner) CanHaveChildren() bool {
return false
}
// newPlainTextInner creates and returns a plain text.
func newPlainTextInner(ln *line, rslt *result, src *source, parent element, insertBr bool, opts *Options) *plainTextInner {
return &plainTextInner{
elementBase: newElementBase(ln, rslt, src, parent, opts),
insertBr: insertBr,
}
}