diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-24 19:37:32 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-24 20:22:21 +0700 |
| commit | 0b28215bf787f257f2ce55fab324efdc5f1145e7 (patch) | |
| tree | dcc50c33996c11b8822c53da4878a8421b0ff166 | |
| parent | 4f2549fb0f3f71ca1e1d1f2b3e80a52887dd616b (diff) | |
| download | asciidoctor-go-0b28215bf787f257f2ce55fab324efdc5f1145e7.tar.xz | |
all: export meta name for author, description, and keywords
By exporting this meta name, any frontend for this library can use
it to check for key and value.
| -rw-r--r-- | document.go | 13 | ||||
| -rw-r--r-- | parser.go | 7 |
2 files changed, 10 insertions, 10 deletions
diff --git a/document.go b/document.go index c4bbd0c..bb51c65 100644 --- a/document.go +++ b/document.go @@ -180,13 +180,13 @@ func (doc *Document) ToHTML(out io.Writer) (err error) { fmt.Fprint(buf, _htmlBegin) - var metaValue string = doc.Attributes[metaNameDescription] + var metaValue string = doc.Attributes[MetaNameDescription] if len(metaValue) > 0 { fmt.Fprintf(buf, "\n<meta name=\"description\" content=%q>", metaValue) } - metaValue = doc.Attributes[metaNameKeywords] + metaValue = doc.Attributes[MetaNameKeywords] if len(metaValue) > 0 { fmt.Fprintf(buf, "\n<meta name=\"keywords\" content=%q>", metaValue) } @@ -203,8 +203,7 @@ func (doc *Document) ToHTML(out io.Writer) (err error) { metaAuthors.WriteString(author.FullName()) } if metaAuthors.Len() > 0 { - fmt.Fprintf(buf, "\n<meta name=%q content=%q>", - attrValueAuthor, metaAuthors.String()) + fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameAuthor, metaAuthors.String()) } var title string = doc.Title.String() @@ -348,7 +347,7 @@ func (doc *Document) unpackRawAuthor() { ) if len(doc.rawAuthors) == 0 { - v = doc.Attributes[metaNameAuthor] + v = doc.Attributes[MetaNameAuthor] if len(v) > 0 { doc.rawAuthors = v } @@ -374,7 +373,7 @@ func (doc *Document) unpackRawAuthor() { } var ( - authorKey = metaNameAuthor + authorKey = MetaNameAuthor emailKey = metaNameEmail initialsKey = metaNameAuthorInitials firstNameKey = metaNameFirstName @@ -395,7 +394,7 @@ func (doc *Document) unpackRawAuthor() { doc.Attributes[lastNameKey] = author.LastName } - authorKey = fmt.Sprintf("%s_%d", metaNameAuthor, x+1) + authorKey = fmt.Sprintf("%s_%d", MetaNameAuthor, x+1) emailKey = fmt.Sprintf("%s_%d", metaNameEmail, x+1) initialsKey = fmt.Sprintf("%s_%d", metaNameAuthorInitials, x+1) firstNameKey = fmt.Sprintf("%s_%d", metaNameFirstName, x+1) @@ -180,15 +180,16 @@ const ( // List of document metadata. const ( - metaNameAuthor = attrValueAuthor + MetaNameAuthor = "author" + MetaNameDescription = "description" + MetaNameKeywords = "keywords" + metaNameAuthorInitials = "authorinitials" - metaNameDescription = "description" metaNameDocTitle = "doctitle" metaNameEmail = attrValueEmail metaNameFirstName = "firstname" metaNameIDPrefix = "idprefix" metaNameIDSeparator = "idseparator" - metaNameKeywords = "keywords" metaNameLastName = "lastname" metaNameMiddleName = "middlename" metaNameNoFooter = "nofooter" |
