diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-24 21:33:49 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-24 21:33:49 +0700 |
| commit | 36e28fcc4292788569b75f7da6cbfdc95a956408 (patch) | |
| tree | 02dbb4234c7cd26add80e9972cc5fcdd452e8c66 | |
| parent | 7e5793e5744dc9d88933eddcb4d1b439b74ddf1e (diff) | |
| download | asciidoctor-go-36e28fcc4292788569b75f7da6cbfdc95a956408.tar.xz | |
all: sort the generated HTML meta by names
The order of meta names are "author", "description", "generator", and
then "keywords".
| -rw-r--r-- | document.go | 18 | ||||
| -rw-r--r-- | html_template.go | 3 | ||||
| -rw-r--r-- | testdata/test.got.html | 6 |
3 files changed, 14 insertions, 13 deletions
diff --git a/document.go b/document.go index 33e3179..2fae03d 100644 --- a/document.go +++ b/document.go @@ -182,24 +182,26 @@ func (doc *Document) ToHTML(out io.Writer) (err error) { // Use *bytes.Buffer to minimize checking for error. var buf = &bytes.Buffer{} - metaValue = doc.Attributes[MetaNameGenerator] + fmt.Fprint(buf, _htmlBegin) - fmt.Fprintf(buf, _htmlBegin, metaValue) + metaValue = doc.Attributes[MetaNameAuthorNames] + if len(metaValue) > 0 { + fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameAuthor, metaValue) + } metaValue = doc.Attributes[MetaNameDescription] if len(metaValue) > 0 { - fmt.Fprintf(buf, "\n<meta name=\"description\" content=%q>", - metaValue) + fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameDescription, metaValue) } - metaValue = doc.Attributes[MetaNameKeywords] + metaValue = doc.Attributes[MetaNameGenerator] if len(metaValue) > 0 { - fmt.Fprintf(buf, "\n<meta name=\"keywords\" content=%q>", metaValue) + fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameGenerator, metaValue) } - metaValue = doc.Attributes[MetaNameAuthorNames] + metaValue = doc.Attributes[MetaNameKeywords] if len(metaValue) > 0 { - fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameAuthor, metaValue) + fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameKeywords, metaValue) } var title string = doc.Title.String() diff --git a/html_template.go b/html_template.go index 86b4bf2..cd173ab 100644 --- a/html_template.go +++ b/html_template.go @@ -10,8 +10,7 @@ const ( <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> -<meta name="viewport" content="width=device-width, initial-scale=1.0"> -<meta name="generator" content="%s">` +<meta name="viewport" content="width=device-width, initial-scale=1.0">` ) const ( diff --git a/testdata/test.got.html b/testdata/test.got.html index 239d8a1..bbd2d62 100644 --- a/testdata/test.got.html +++ b/testdata/test.got.html @@ -4,10 +4,10 @@ <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> -<meta name="generator" content="asciidoctor-go 0.3.0-alpha"> +<meta name="author" content="Author A, Author mid dle B"> <meta name="description" content="meta description"> +<meta name="generator" content="asciidoctor-go 0.3.0-alpha"> <meta name="keywords" content="key, words"> -<meta name="author" content="Author A, Author mid dle B"> <title>Example Document title</title> <style> @@ -2956,7 +2956,7 @@ this sidebar.</p> <div id="footer"> <div id="footer-text"> 1.1.1<br> -Last updated 2022-07-24 20:18:18 +0700 +Last updated 2022-07-24 21:29:04 +0700 </div> </div> </body> |
