diff options
| author | Shulhan <ms@kilabit.info> | 2020-04-18 16:38:29 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2020-10-07 16:37:20 +0700 |
| commit | 396d45eee46ad4dcf33c224053e79373cf881f77 (patch) | |
| tree | e99339acbe639b3a2fbdfc11775666f35fa71951 /filehtml.go | |
| parent | 2a480f6b856367ac5cc0102c4ae92eb6814228da (diff) | |
| download | ciigo-396d45eee46ad4dcf33c224053e79373cf881f77.tar.xz | |
all: update to libasciidoc v0.5.1
The latest release of libasciidoc changes the API to convert adoc content
to HTML.
Instead of one call, we need to call ParseDocument first to get
the document metadata (Attributes) and then call Convert() to convert it
to HTML.
Diffstat (limited to 'filehtml.go')
| -rw-r--r-- | filehtml.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/filehtml.go b/filehtml.go index fb11eee..c3f06e6 100644 --- a/filehtml.go +++ b/filehtml.go @@ -5,8 +5,11 @@ package ciigo import ( + "fmt" "html/template" "strings" + + "github.com/bytesparadise/libasciidoc/pkg/types" ) // @@ -67,3 +70,24 @@ func (fhtml *fileHTML) unpackMarkup(fa *fileMarkup) { fhtml.Body = template.HTML(fhtml.rawBody.String()) // nolint:gosec } + +func (fhtml *fileHTML) unpackAdocMetadata(doc types.Document, md types.Metadata) { + fhtml.Metadata = make(map[string]string) + fhtml.Date = md.LastUpdated + fhtml.Title = md.Title + + for k, v := range doc.Attributes { + switch k { + case metadataAuthor: + fhtml.Author, _ = v.(string) + case metadataDate: + fhtml.Date, _ = v.(string) + case metadataTitle: + fhtml.Title, _ = v.(string) + case metadataStylesheet: + fhtml.Styles = append(fhtml.Styles, v.(string)) + default: + fhtml.Metadata[k] = fmt.Sprintf("%v", v) + } + } +} |
