Skip to content

Commit

Permalink
don't run HTML files through Markdown and use strings.Builder as Writ…
Browse files Browse the repository at this point in the history
…er for markdown output
  • Loading branch information
dannyvankooten committed Nov 24, 2023
1 parent 8cee5ed commit 1c39f08
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1c39f08

Please sign in to comment.