aboutsummaryrefslogtreecommitdiff
path: root/hswg/main.go
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-03-03 14:28:15 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-03-20 23:28:45 +0100
commit442fa5d6607d6188be01d342e1bc7d24b977bd22 (patch)
tree7957c54e1efc9a243b5b5d154bf3cd3c63be5cfe /hswg/main.go
parent8b376694d39e7cf1e35e6ac7f603a552fa81b23f (diff)
downloadhaven-442fa5d6607d6188be01d342e1bc7d24b977bd22.tar.gz
haven-442fa5d6607d6188be01d342e1bc7d24b977bd22.tar.xz
haven-442fa5d6607d6188be01d342e1bc7d24b977bd22.zip
Bump libasciidoc
Diffstat (limited to 'hswg/main.go')
-rw-r--r--hswg/main.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/hswg/main.go b/hswg/main.go
index 313d2ff..458fe87 100644
--- a/hswg/main.go
+++ b/hswg/main.go
@@ -63,7 +63,7 @@ func (m *Metadata) AttrList(name string) []string {
// Render converts an io.Reader with an AsciiDoc document to HTML. So long as
// the file could be read at all, it will always return a non-empty document.
-func Render(r io.Reader, config configuration.Configuration) (
+func Render(r io.Reader, config *configuration.Configuration) (
html *bytes.Buffer, meta Metadata, err error) {
html = bytes.NewBuffer(nil)
@@ -81,9 +81,11 @@ func Render(r io.Reader, config configuration.Configuration) (
// io.Copy(os.Stdout, pr)
// return
- var doc types.Document
+ var doc *types.Document
if doc, err = parser.ParseDocument(pr, config); err == nil {
- problems, verr := validator.Validate(&doc)
+ doctype := config.Attributes.GetAsStringWithDefault(
+ types.AttrDocType, "article")
+ problems, verr := validator.Validate(doc, doctype)
if verr != nil {
fmt.Fprintln(os.Stderr, verr)
}
@@ -104,7 +106,7 @@ func Render(r io.Reader, config configuration.Configuration) (
}
_, _ = html.WriteString("</pre>")
}
- meta.Attributes = doc.Attributes
+ meta.Attributes = config.Attributes
return
}