From 1c39f08277842c0b67633f7a60acb46067f680df Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Fri, 24 Nov 2023 08:25:10 +0100 Subject: [PATCH] don't run HTML files through Markdown and use strings.Builder as Writer for markdown output --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 3732280..f2975c3 100644 --- a/main.go +++ b/main.go @@ -125,13 +125,17 @@ func (p *Page) ParseContent() (string, error) { fileContent = fileContent[pos+6:] } - // TODO: Only process Markdown if this is a .md file - var buf bytes.Buffer - if err := md.Convert(fileContent, &buf); err != nil { - return "", err + // If source file has HTML extension, return content directly + if strings.HasSuffix(p.Filepath, ".html") { + return string(fileContent), nil } - return string(buf.Bytes()), nil + // Otherwise, parse as Markdown + var buf2 strings.Builder + if err := md.Convert(fileContent, &buf2); err != nil { + return "", err + } + return buf2.String(), nil } func (s *Site) buildPage(p *Page) error {