summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/markup/csv/csv.go3
-rw-r--r--modules/markup/external/external.go5
-rw-r--r--modules/markup/markdown/markdown.go3
-rw-r--r--modules/markup/markup.go12
-rw-r--r--modules/markup/orgmode/orgmode.go3
-rw-r--r--modules/setting/markup.go22
6 files changed, 34 insertions, 14 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"}
diff --git a/modules/setting/markup.go b/modules/setting/markup.go
index 1dd76243e6..36cba68262 100644
--- a/modules/setting/markup.go
+++ b/modules/setting/markup.go
@@ -21,11 +21,12 @@ var (
// MarkupParser defines the external parser configured in ini
type MarkupParser struct {
- Enabled bool
- MarkupName string
- Command string
- FileExtensions []string
- IsInputFile bool
+ Enabled bool
+ MarkupName string
+ Command string
+ FileExtensions []string
+ IsInputFile bool
+ NeedPostProcess bool
}
// MarkupSanitizerRule defines the policy for whitelisting attributes on
@@ -124,10 +125,11 @@ func newMarkupRenderer(name string, sec *ini.Section) {
}
ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
- Enabled: sec.Key("ENABLED").MustBool(false),
- MarkupName: name,
- FileExtensions: exts,
- Command: command,
- IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
+ Enabled: sec.Key("ENABLED").MustBool(false),
+ MarkupName: name,
+ FileExtensions: exts,
+ Command: command,
+ IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
+ NeedPostProcess: sec.Key("NEED_POSTPROCESS").MustBool(true),
})
}