diff options
| author | Shulhan <ms@kilabit.info> | 2025-04-18 19:35:03 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-04-18 19:35:03 +0700 |
| commit | 7aef4c19dd9b4b9da2460e22395b6a25a476100f (patch) | |
| tree | ae5ab80fc8b85d1dba18f9aad343dda1836d1abd | |
| parent | 984b3b2c912616de5d8c2de766d4897c255d563e (diff) | |
| download | asciidoctor-go-7aef4c19dd9b4b9da2460e22395b6a25a476100f.tar.xz | |
all: fix the logic when applying default embedded CSS
By default, the document contains ":stylesheet:" attribute, which
means using the default embedded CSS.
To disable it, unset the attribute using ":stylesheet!:".
To overwrite it, set the attribute to path of CSS file
":stylesheet: my.css".
While at it, export the DocAttrStylesheet.
| -rw-r--r-- | document.go | 4 | ||||
| -rw-r--r-- | document_attribute.go | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/document.go b/document.go index aa89434..1fa88ed 100644 --- a/document.go +++ b/document.go @@ -215,8 +215,8 @@ func (doc *Document) ToHTML(out io.Writer) (err error) { var ok bool - _, ok = doc.Attributes.Entry[docAttrStylesheet] - if ok { + docAttrValue, ok = doc.Attributes.Entry[DocAttrStylesheet] + if ok && len(docAttrValue) == 0 { buf.WriteByte('\n') buf.WriteString(_defaultCSS) } diff --git a/document_attribute.go b/document_attribute.go index 9419084..3217c16 100644 --- a/document_attribute.go +++ b/document_attribute.go @@ -11,6 +11,13 @@ const ( DocAttrGenerator = `generator` DocAttrKeywords = `keywords` + // By default, the document contains ":stylesheet:" attribute, which + // means using the default embedded CSS. + // To disable it, unset the attribute using ":stylesheet!:". + // To overwrite it, set the attribute to path of CSS file + // ":stylesheet: my.css". + DocAttrStylesheet = `stylesheet` + docAttrAuthorInitials = `authorinitials` docAttrDocdir = `docdir` docAttrDocTitle = `doctitle` @@ -36,7 +43,6 @@ const ( docAttrSectNumLevel = `sectnumlevels` docAttrSectNums = `sectnums` docAttrShowTitle = `showtitle` - docAttrStylesheet = `stylesheet` docAttrTOC = `toc` docAttrTOCLevels = `toclevels` docAttrTOCTitle = `toc-title` @@ -70,7 +76,7 @@ func newDocumentAttribute() DocumentAttribute { docAttrLastUpdateValue: ``, docAttrSectIDs: ``, docAttrShowTitle: ``, - docAttrStylesheet: ``, + DocAttrStylesheet: ``, // Default to embedded CSS. docAttrTableCaption: ``, docAttrVersionLabel: ``, }, |
