Replies: 1 comment
-
You can override the parser used by goldmark to remove the defaults. Here's an example with a bunch of the defaults disabled: package main
import (
"fmt"
"strings"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/parser"
"github.com/yuin/goldmark/util"
)
func main() {
parserWithoutFeatures := parser.NewParser(
parser.WithBlockParsers(
//util.Prioritized(parser.NewSetextHeadingParser(), 100),
util.Prioritized(parser.NewThematicBreakParser(), 200),
//util.Prioritized(parser.NewListParser(), 300),
//util.Prioritized(parser.NewListItemParser(), 400),
//util.Prioritized(parser.NewCodeBlockParser(), 500),
//util.Prioritized(parser.NewATXHeadingParser(), 600),
//util.Prioritized(parser.NewFencedCodeBlockParser(), 700),
//util.Prioritized(parser.NewBlockquoteParser(), 800),
//util.Prioritized(parser.NewHTMLBlockParser(), 900),
util.Prioritized(parser.NewParagraphParser(), 1000),
),
parser.WithInlineParsers(
//util.Prioritized(parser.NewCodeSpanParser(), 100),
util.Prioritized(parser.NewLinkParser(), 200),
util.Prioritized(parser.NewAutoLinkParser(), 300),
//util.Prioritized(parser.NewRawHTMLParser(), 400),
util.Prioritized(parser.NewEmphasisParser(), 500),
),
parser.WithParagraphTransformers(
util.Prioritized(parser.LinkReferenceParagraphTransformer, 100),
),
)
markdown := goldmark.New(goldmark.WithParser(parserWithoutFeatures))
var buf strings.Builder
markdown.Convert([]byte(`# Hello world (no headings)
* No lists `+"`or code`"+`
**Yes bold *and italic***, [also links](https://example.com)
`), &buf)
fmt.Println(buf.String())
} Output:
The list of defaults is in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to have multiple filters per user roles so certain users can use links, images or bold text, for example, but others can not. Is there a way to configure goldmark this way or do I have to run it through something like bluemonday afterwards(which seems like not an ideal solution)? The way goldmark works is it gives option to add features but not remove them(it lacks configuration for core features and extensions).
Beta Was this translation helpful? Give feedback.
All reactions