33 lines
651 B
Go
33 lines
651 B
Go
package models
|
|
|
|
import (
|
|
"brainminder.speedtech.it/internal/database"
|
|
"github.com/yuin/goldmark"
|
|
highlighting "github.com/yuin/goldmark-highlighting"
|
|
"github.com/yuin/goldmark/extension"
|
|
"github.com/yuin/goldmark/renderer/html"
|
|
)
|
|
|
|
type BaseModel struct {
|
|
DB *database.DB
|
|
}
|
|
|
|
func (model *BaseModel) GetMarkdown() *goldmark.Markdown {
|
|
markdown := goldmark.New(
|
|
goldmark.WithRendererOptions(
|
|
html.WithXHTML(),
|
|
html.WithUnsafe(),
|
|
),
|
|
goldmark.WithExtensions(
|
|
highlighting.Highlighting,
|
|
extension.NewLinkify(
|
|
extension.WithLinkifyAllowedProtocols([]string{
|
|
"http:",
|
|
"https:",
|
|
}),
|
|
),
|
|
),
|
|
)
|
|
return &markdown
|
|
}
|