Change markdown dialect to gfm
This commit is contained in:
parent
1647a7187e
commit
98af3c6b4e
@ -21,7 +21,7 @@ func ConvertToMarkdown(c *Config, filename string) ([]byte, error) {
|
|||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
articleFileName := filepath.Join(os.TempDir(), fmt.Sprint(uuid.New(), ".md"))
|
articleFileName := filepath.Join(os.TempDir(), fmt.Sprint(uuid.New(), ".md"))
|
||||||
cmd := exec.Command("pandoc", "-s", "-L", filepath.Join("scripts", "create_toc.lua"), "-f", "docx", "-t", "commonmark_x", "-o", articleFileName, "--extract-media", tmpDir, filename) // TODO: Is writing to a file necessary?
|
cmd := exec.Command("pandoc", "-s", "-L", filepath.Join("scripts", "create_toc.lua"), "-f", "docx", "-t", "gfm", "-o", articleFileName, "--extract-media", tmpDir, filename) // TODO: Is writing to a file necessary?
|
||||||
cmd.Stderr = &stderr
|
cmd.Stderr = &stderr
|
||||||
if err = cmd.Run(); err != nil {
|
if err = cmd.Run(); err != nil {
|
||||||
return nil, fmt.Errorf("error converting docx to markdown: %v: %v", err, stderr.String())
|
return nil, fmt.Errorf("error converting docx to markdown: %v: %v", err, stderr.String())
|
||||||
|
@ -6,12 +6,19 @@ import (
|
|||||||
|
|
||||||
"github.com/microcosm-cc/bluemonday"
|
"github.com/microcosm-cc/bluemonday"
|
||||||
"github.com/yuin/goldmark"
|
"github.com/yuin/goldmark"
|
||||||
|
"github.com/yuin/goldmark/extension"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ConvertToHTML(md string) (string, error) {
|
func ConvertToHTML(md string) (string, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if err := goldmark.Convert([]byte(md), &buf); err != nil {
|
gm := goldmark.New(
|
||||||
|
goldmark.WithExtensions(
|
||||||
|
extension.GFM,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
if err := gm.Convert([]byte(md), &buf); err != nil {
|
||||||
return "", fmt.Errorf("error converting markdown to html: %v", err)
|
return "", fmt.Errorf("error converting markdown to html: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user