diff options
Diffstat (limited to 'modules/markup')
-rw-r--r-- | modules/markup/csv/csv.go | 3 | ||||
-rw-r--r-- | modules/markup/external/external.go | 5 | ||||
-rw-r--r-- | modules/markup/markdown/markdown.go | 3 | ||||
-rw-r--r-- | modules/markup/markup.go | 12 | ||||
-rw-r--r-- | modules/markup/orgmode/orgmode.go | 3 |
5 files changed, 22 insertions, 4 deletions
diff --git a/modules/markup/csv/csv.go b/modules/markup/csv/csv.go index 430e759eb5..68c89166b5 100644 --- a/modules/markup/csv/csv.go +++ b/modules/markup/csv/csv.go @@ -28,6 +28,9 @@ func (Parser) Name() string { return "csv" } +// NeedPostProcess implements markup.Parser +func (Parser) NeedPostProcess() bool { return false } + // Extensions implements markup.Parser func (Parser) Extensions() []string { return []string{".csv", ".tsv"} diff --git a/modules/markup/external/external.go b/modules/markup/external/external.go index 7acf936171..6e7e59970d 100644 --- a/modules/markup/external/external.go +++ b/modules/markup/external/external.go @@ -38,6 +38,11 @@ func (p *Parser) Name() string { return p.MarkupName } +// NeedPostProcess implements markup.Parser +func (p *Parser) NeedPostProcess() bool { + return p.MarkupParser.NeedPostProcess +} + // Extensions returns the supported extensions of the tool func (p *Parser) Extensions() []string { return p.FileExtensions diff --git a/modules/markup/markdown/markdown.go b/modules/markup/markdown/markdown.go index 93235d77e5..5bb0fbd652 100644 --- a/modules/markup/markdown/markdown.go +++ b/modules/markup/markdown/markdown.go @@ -228,6 +228,9 @@ func (Parser) Name() string { return MarkupName } +// NeedPostProcess implements markup.Parser +func (Parser) NeedPostProcess() bool { return true } + // Extensions implements markup.Parser func (Parser) Extensions() []string { return setting.Markdown.FileExtensions diff --git a/modules/markup/markup.go b/modules/markup/markup.go index f8deb2b29b..bc35757775 100644 --- a/modules/markup/markup.go +++ b/modules/markup/markup.go @@ -33,6 +33,7 @@ func Init() { type Parser interface { Name() string // markup format name Extensions() []string + NeedPostProcess() bool 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 { result := parser.Render(rawBytes, urlPrefix, metas, isWiki) - // TODO: one day the error should be returned. - result, err := PostProcess(result, urlPrefix, metas, isWiki) - if err != nil { - log.Error("PostProcess: %v", err) + if parser.NeedPostProcess() { + var err error + // TODO: one day the error should be returned. + result, err = PostProcess(result, urlPrefix, metas, isWiki) + if err != nil { + log.Error("PostProcess: %v", err) + } } return SanitizeBytes(result) } diff --git a/modules/markup/orgmode/orgmode.go b/modules/markup/orgmode/orgmode.go index ddd445aba2..b445b76956 100644 --- a/modules/markup/orgmode/orgmode.go +++ b/modules/markup/orgmode/orgmode.go @@ -30,6 +30,9 @@ func (Parser) Name() string { return "orgmode" } +// NeedPostProcess implements markup.Parser +func (Parser) NeedPostProcess() bool { return true } + // Extensions implements markup.Parser func (Parser) Extensions() []string { return []string{".org"} |