|
|
@ -33,6 +33,7 @@ func Init() { |
|
|
|
type Parser interface { |
|
|
|
type Parser interface { |
|
|
|
Name() string // markup format name
|
|
|
|
Name() string // markup format name
|
|
|
|
Extensions() []string |
|
|
|
Extensions() []string |
|
|
|
|
|
|
|
NeedPostProcess() bool |
|
|
|
Render(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte |
|
|
|
Render(rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -82,10 +83,13 @@ func RenderWiki(filename string, rawBytes []byte, urlPrefix string, metas map[st |
|
|
|
|
|
|
|
|
|
|
|
func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte { |
|
|
|
func render(parser Parser, rawBytes []byte, urlPrefix string, metas map[string]string, isWiki bool) []byte { |
|
|
|
result := parser.Render(rawBytes, urlPrefix, metas, isWiki) |
|
|
|
result := parser.Render(rawBytes, urlPrefix, metas, isWiki) |
|
|
|
// TODO: one day the error should be returned.
|
|
|
|
if parser.NeedPostProcess() { |
|
|
|
result, err := PostProcess(result, urlPrefix, metas, isWiki) |
|
|
|
var err error |
|
|
|
if err != nil { |
|
|
|
// TODO: one day the error should be returned.
|
|
|
|
log.Error("PostProcess: %v", err) |
|
|
|
result, err = PostProcess(result, urlPrefix, metas, isWiki) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Error("PostProcess: %v", err) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return SanitizeBytes(result) |
|
|
|
return SanitizeBytes(result) |
|
|
|
} |
|
|
|
} |
|
|
|