summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-03-02 23:37:49 +0700
committerShulhan <ms@kilabit.info>2023-03-02 23:37:49 +0700
commit6ce03f696112a0cb2db2898778312fc32b62439d (patch)
treeeeae625cc99dac929e0d20f44663e66aceb286f2
parentfe8bd4d6305e82259eaac94972f1621aa52e89aa (diff)
downloadasciidoctor-go-6ce03f696112a0cb2db2898778312fc32b62439d.tar.xz
all: fix empty line printed on ToHTMLBody or ToHTMLEmbedded
Given the following adoc, ---- = T ---- If we call ToHTMLBody, the output is ---- <div id="header"> <h1>T</h1> ---- This changes fix the empty line at the top.
-rw-r--r--document.go2
-rw-r--r--html_backend.go2
-rw-r--r--testdata/author_test.txt4
-rw-r--r--testdata/document_title_test.txt4
-rw-r--r--testdata/header_with_empty_line_test.txt1
-rw-r--r--testdata/meta_showtitle_test.txt2
6 files changed, 2 insertions, 13 deletions
diff --git a/document.go b/document.go
index 97c8171..f716dd9 100644
--- a/document.go
+++ b/document.go
@@ -211,7 +211,7 @@ func (doc *Document) ToHTML(out io.Writer) (err error) {
fmt.Fprintf(buf, "\n<title>%s</title>", title)
}
- fmt.Fprintf(buf, "\n</head>\n<body class=%q>", doc.classes.String())
+ fmt.Fprintf(buf, "\n</head>\n<body class=%q>\n", doc.classes.String())
var (
isWithHeaderFooter = true
diff --git a/html_backend.go b/html_backend.go
index 100fab1..ff51447 100644
--- a/html_backend.go
+++ b/html_backend.go
@@ -976,7 +976,7 @@ func htmlWriteFootnoteDefs(doc *Document, out io.Writer) {
}
func htmlWriteHeader(doc *Document, out io.Writer) {
- fmt.Fprint(out, "\n<div id=\"header\">")
+ fmt.Fprint(out, `<div id="header">`)
var (
haveHeader = doc.haveHeader()
diff --git a/testdata/author_test.txt b/testdata/author_test.txt
index 40dbfd8..6e43066 100644
--- a/testdata/author_test.txt
+++ b/testdata/author_test.txt
@@ -5,7 +5,6 @@ output_call: htmlWriteHeader
A B
<<< single author
-
<div id="header">
<h1>T</h1>
<div class="details">
@@ -18,7 +17,6 @@ A B
A B <a@b>
<<< single author with email
-
<div id="header">
<h1>T</h1>
<div class="details">
@@ -32,7 +30,6 @@ A B <a@b>
A B <a@b>; C <c@c>; D e_f G <>;
<<< Multiple authors
-
<div id="header">
<h1>T</h1>
<div class="details">
@@ -50,7 +47,6 @@ A B <a@b>; C <c@c>; D e_f G <>;
:email: a@b
<<< Meta author
-
<div id="header">
<h1>T</h1>
<div class="details">
diff --git a/testdata/document_title_test.txt b/testdata/document_title_test.txt
index 14098ca..9856204 100644
--- a/testdata/document_title_test.txt
+++ b/testdata/document_title_test.txt
@@ -4,7 +4,6 @@ output_call: htmlWriteHeader
= Main: sub
<<<
-
<div id="header">
<h1>Main: sub</h1>
</div>
@@ -13,7 +12,6 @@ output_call: htmlWriteHeader
= Main:sub
<<< Without space after separator
-
<div id="header">
<h1>Main:sub</h1>
</div>
@@ -22,7 +20,6 @@ output_call: htmlWriteHeader
= a: b: c
<<< With multiple separator after separator
-
<div id="header">
<h1>a: b: c</h1>
</div>
@@ -32,7 +29,6 @@ output_call: htmlWriteHeader
= Mainx sub
<<< With custom separator
-
<div id="header">
<h1>Mainx sub</h1>
</div>
diff --git a/testdata/header_with_empty_line_test.txt b/testdata/header_with_empty_line_test.txt
index c4a4a63..c164769 100644
--- a/testdata/header_with_empty_line_test.txt
+++ b/testdata/header_with_empty_line_test.txt
@@ -11,7 +11,6 @@ Below is empty line with spaces.
= Title
<<<
-
<div id="header">
</div>
<div id="content">
diff --git a/testdata/meta_showtitle_test.txt b/testdata/meta_showtitle_test.txt
index 163f264..95607d0 100644
--- a/testdata/meta_showtitle_test.txt
+++ b/testdata/meta_showtitle_test.txt
@@ -4,7 +4,6 @@ output_call: ToHTMLBody
= Abc
<<<
-
<div id="header">
<h1>Abc</h1>
</div>
@@ -20,7 +19,6 @@ output_call: ToHTMLBody
:showtitle!:
<<< With meta showtitle off
-
<div id="header">
</div>
<div id="content">