aboutsummaryrefslogtreecommitdiff
path: root/filehtml.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-08-01 02:11:00 +0700
committerShulhan <ms@kilabit.info>2022-08-01 02:11:51 +0700
commit3f36d9d317263f6c65f7ec4ebb4b704d7dafe00b (patch)
tree6c78ccda08183dc1b94003ccbd9a6815d7ff2aad /filehtml.go
parent8d347992ab2753dc878f56439883ec868e8d038d (diff)
downloadciigo-3f36d9d317263f6c65f7ec4ebb4b704d7dafe00b.tar.xz
all: export convert method in Converter as ToHtmlFile
This is the first public API provided for Converter, as promised in the previous commit.
Diffstat (limited to 'filehtml.go')
-rw-r--r--filehtml.go19
1 files changed, 8 insertions, 11 deletions
diff --git a/filehtml.go b/filehtml.go
index 202c605..5d889a0 100644
--- a/filehtml.go
+++ b/filehtml.go
@@ -5,8 +5,6 @@ package ciigo
import (
"html/template"
- "io/fs"
- "os"
"strings"
"git.sr.ht/~shulhan/asciidoctor-go"
@@ -24,25 +22,26 @@ type fileHtml struct {
Body template.HTML
Metadata map[string]string
- path string
- finfo fs.FileInfo
rawBody strings.Builder
}
-func newFileHtml(path string) (fhtml *fileHtml) {
+func newFileHtml() (fhtml *fileHtml) {
fhtml = &fileHtml{
- path: path,
+ Metadata: map[string]string{},
}
- fhtml.finfo, _ = os.Stat(path)
return fhtml
}
func (fhtml *fileHtml) unpackAdocMetadata(doc *asciidoctor.Document) {
+ var (
+ k string
+ v string
+ )
+
fhtml.Title = doc.Title.String()
fhtml.Styles = fhtml.Styles[:0]
- fhtml.Metadata = make(map[string]string, len(doc.Attributes))
- for k, v := range doc.Attributes {
+ for k, v = range doc.Attributes {
switch k {
case metadataStylesheet:
fhtml.Styles = append(fhtml.Styles, v)
@@ -58,6 +57,4 @@ func (fhtml *fileHtml) unpackAdocMetadata(doc *asciidoctor.Document) {
if len(fhtml.Styles) == 0 {
fhtml.EmbeddedCSS = embeddedCSS()
}
-
- fhtml.Body = template.HTML(fhtml.rawBody.String())
}