diff options
author | clsr <clsr@clsr.net> | 2017-08-24 15:55:47 +0200 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2017-08-24 15:55:47 +0200 |
commit | 27a229a06f0354ee16bb97e6cf2dd1780923e74f (patch) | |
tree | 71ab917178a7615d8689df7cd6f2ae26398c4e46 /document.go | |
parent | d62b2f6de6854b107601ea82611b845c6f830237 (diff) | |
download | cnm-go-27a229a06f0354ee16bb97e6cf2dd1780923e74f.tar.gz cnm-go-27a229a06f0354ee16bb97e6cf2dd1780923e74f.zip |
Make Document a Block
Diffstat (limited to 'document.go')
-rw-r--r-- | document.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/document.go b/document.go index b5cdbe5..5137b80 100644 --- a/document.go +++ b/document.go @@ -63,6 +63,27 @@ func ParseDocument(r io.Reader) (doc *Document, err error) { return } +// Name returns an empty string (top-level block context has no name). +func (doc *Document) Name() string { + return "" +} + +// Args returns a nil slice (top-level block context has no args). +func (doc *Document) Args() []string { + return nil +} + +// WriteIndent writes the document to w. +// +// n must be 0 or this function will panic. +func (doc *Document) WriteIndent(w io.Writer, n int) error { + if n != 0 { + panic("cnm-go: Document.WriteIndent: n must be 0") + } + return doc.Write(w) +} + +// Write writes the document to w. func (doc *Document) Write(w io.Writer) error { bw := bufio.NewWriter(w) if doc.Title != "" { |