diff --git a/go.mod b/go.mod index 378150c..589ab03 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module poyossg go 1.27.1 + +require github.com/gomarkdown/markdown v0.0.0-20260923180740-94fc73f6b1a3 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..29bca07 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/gomarkdown/markdown v0.0.0-20260923180740-94fc73f6b1a3 h1:tTy9EC3uLxFeMrYCOf+T4cS86imMT6kGMl7htiU907o= +github.com/gomarkdown/markdown v0.0.0-20260923180740-94fc73f6b1a3/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA= diff --git a/main.go b/main.go index c3618fb..6a88662 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( ) const CONTENT_DIR = "./content" +const OUTPUT_DIR = "./_dist" const UNTITLED_POST = "Untitled rambling." func main() { diff --git a/markdown.go b/markdown.go new file mode 100644 index 0000000..77d2326 --- /dev/null +++ b/markdown.go @@ -0,0 +1,20 @@ +package main + +import ( + "github.com/gomarkdown/markdown" + "github.com/gomarkdown/markdown/html" + "github.com/gomarkdown/markdown/parser" +) + +func mdToHtml(input []byte) []byte { + extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock + p := parser.NewWithExtensions(extensions) + doc := p.Parse(input) + + // create HTML renderer with extensions + htmlFlags := html.CommonFlags | html.HrefTargetBlank + opts := html.RendererOptions{Flags: htmlFlags} + renderer := html.NewRenderer(opts) + + return markdown.Render(doc, renderer) +}