aboutsummaryrefslogtreecommitdiff
path: root/filehtml.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2020-05-01 13:30:42 +0700
committerShulhan <ms@kilabit.info>2020-05-01 13:30:42 +0700
commit9039448f8a91ee96ecea1c7c78ccaf81f4699e92 (patch)
tree376d09cdf6d18573ee334887b6c33a39910c501e /filehtml.go
parentf6811267d6c7985d75f4bec491c26521e88ea514 (diff)
downloadciigo-9039448f8a91ee96ecea1c7c78ccaf81f4699e92.tar.xz
all: embed the HTML template and the stylesheet
The parameter for template either in Convert or Generate functions or in CLI now become pure optional, not default to "templates/html.tmpl" anymore. This will minimize steps for user to setup or run the library or program.
Diffstat (limited to 'filehtml.go')
-rw-r--r--filehtml.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/filehtml.go b/filehtml.go
index 7eeda71..fb11eee 100644
--- a/filehtml.go
+++ b/filehtml.go
@@ -13,12 +13,13 @@ import (
// fileHTML represent an HTML metadata for header and its body.
//
type fileHTML struct {
- Title string
- Author string
- Date string
- Styles []string
- Body template.HTML
- Metadata map[string]string
+ Title string
+ Author string
+ Date string
+ EmbeddedCSS *template.CSS
+ Styles []string
+ Body template.HTML
+ Metadata map[string]string
path string
rawBody strings.Builder
@@ -31,6 +32,7 @@ func (fhtml *fileHTML) reset() {
fhtml.Title = ""
fhtml.Author = ""
fhtml.Date = ""
+ fhtml.EmbeddedCSS = nil
fhtml.Styles = fhtml.Styles[:0]
fhtml.Body = template.HTML("")
@@ -59,6 +61,9 @@ func (fhtml *fileHTML) unpackMarkup(fa *fileMarkup) {
fhtml.Metadata[k] = v.(string)
}
}
+ if len(fhtml.Styles) == 0 {
+ fhtml.EmbeddedCSS = embeddedCSS()
+ }
fhtml.Body = template.HTML(fhtml.rawBody.String()) // nolint:gosec
}