From 27a229a06f0354ee16bb97e6cf2dd1780923e74f Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 24 Aug 2017 15:55:47 +0200 Subject: Make Document a Block --- document.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 != "" { -- cgit