hidrocor

commit 0410772b01b1d12ef64624486c66e3c2926f01d5

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

markdown: delete middleware

To be honest we should investigate more on this end, but I don't have
the time or energy to deal with shitty goldmark bugs

 markdown.go | 63 -------------------------------------------------------


diff --git a/markdown.go b/markdown.go
deleted file mode 100644
index d1cf44eb2859d766b43186df7326fe54a138766e..0000000000000000000000000000000000000000
--- a/markdown.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// This package holds the context that given a route, it'll pipe to wiki.Lookup
-// and output a markdown file converted to html. We'll use it later to feed
-// into our main HTML template.
-
-package hidrocor
-
-import (
-	"context"
-	"os"
-	"net/http"
-	"github.com/yuin/goldmark"
-	"github.com/yuin/goldmark/extension"
-	"github.com/yuin/goldmark/parser"
-	"github.com/yuin/goldmark/renderer/html"
-)
-
-type contextKey struct {
-	name string
-}
-
-var mdCtxKey = &contextKey{"markdown"}
-
-func Middleware() func(next http.Handler) http.Handler {
-	return func(next http.Handler) http.Handler {
-		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-			md := goldmark.New(
-				goldmark.WithExtensions(
-					extension.GFM,
-					extension.Linkify,
-					extension.Table,
-					extension.TaskList,
-					extension.DefinitionList,
-					extension.Strikethrough,
-					extension.Footnote,
-				),
-				goldmark.WithParserOptions(
-					parser.WithAutoHeadingID(),
-				),
-				goldmark.WithRendererOptions(
-					html.WithHardWraps(),
-				),
-			)
-
-			r = r.WithContext(Context(r.Context(), md))
-
-			next.ServeHTTP(w, r)
-		})
-	}
-}
-
-func Context(ctx context.Context, md goldmark.Markdown) context.Context {
-	return context.WithValue(ctx, mdCtxKey, md)
-}
-
-func ForContext(ctx context.Context) *goldmark.Markdown {
-	raw, ok := ctx.Value(mdCtxKey).(*goldmark.Markdown)
-
-	if !ok {
-		panic(errors.New("Invalid markdown context"))
-	}
-
-	return raw
-}