Skip to content

Commit abe3ce1

Browse files
committed
修复生成幻灯片页面开头的空格问题
1 parent f3c28b1 commit abe3ce1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/render/slide.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ func (p *BookRendor) renderTalkPages(path string) error {
4242
t := template.Must(present.Template().Parse(tmplPresent))
4343
t = template.Must(t.Parse(tmplAction))
4444

45-
var buf bytes.Buffer
46-
if err = doc.Render(&buf, t); err != nil {
47-
return err
45+
var htmlContent []byte
46+
{
47+
var buf bytes.Buffer
48+
if err = doc.Render(&buf, t); err != nil {
49+
return err
50+
}
51+
htmlContent = bytes.TrimSpace(buf.Bytes())
4852
}
4953

5054
dstAbsPath := filepath.Join(p.Book.Root, "book", path)
@@ -54,7 +58,7 @@ func (p *BookRendor) renderTalkPages(path string) error {
5458
dstAbsPath += ".html"
5559

5660
os.MkdirAll(filepath.Dir(dstAbsPath), 0777)
57-
if err := os.WriteFile(dstAbsPath, buf.Bytes(), 0666); err != nil {
61+
if err := os.WriteFile(dstAbsPath, htmlContent, 0666); err != nil {
5862
return err
5963
}
6064

0 commit comments

Comments
 (0)