summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-09-01 08:32:02 -0400
committerUnknwon <u@gogs.io>2015-09-01 08:32:02 -0400
commit90a6553c37d16a536a24ae26fa9ef5ee4eafaf99 (patch)
tree2ad0757e9dfaf9e697ab88a6c5950721ab387b97 /modules
parent50dbc2732bd77bccfaf9ca25bf0bfa336555fe8c (diff)
downloadgitea-90a6553c37d16a536a24ae26fa9ef5ee4eafaf99.tar.gz
gitea-90a6553c37d16a536a24ae26fa9ef5ee4eafaf99.zip
#1009 Config option for preserving hard line breaks
Diffstat (limited to 'modules')
-rw-r--r--modules/base/markdown.go4
-rw-r--r--modules/setting/setting.go14
2 files changed, 15 insertions, 3 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index 03f1287c1d..540ee58f47 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -201,6 +201,10 @@ func RenderRawMarkdown(body []byte, urlPrefix string) []byte {
extensions |= blackfriday.EXTENSION_SPACE_HEADERS
extensions |= blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK
+ if setting.Markdown.EnableHardLineBreak {
+ extensions |= blackfriday.EXTENSION_HARD_LINE_BREAK
+ }
+
body = blackfriday.Markdown(body, renderer, extensions)
return body
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 009e14a4ae..7b6c496141 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -94,6 +94,11 @@ var (
ExplorePagingNum int
IssuePagingNum int
+ // Markdown sttings.
+ Markdown struct {
+ EnableHardLineBreak bool
+ }
+
// Picture settings.
PictureService string
AvatarUploadPath string
@@ -353,8 +358,9 @@ func NewConfigContext() {
AnsiCharset = sec.Key("ANSI_CHARSET").MustString("")
// UI settings.
- ExplorePagingNum = Cfg.Section("ui").Key("EXPLORE_PAGING_NUM").MustInt(20)
- IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)
+ sec = Cfg.Section("ui")
+ ExplorePagingNum = sec.Key("EXPLORE_PAGING_NUM").MustInt(20)
+ IssuePagingNum = sec.Key("ISSUE_PAGING_NUM").MustInt(10)
sec = Cfg.Section("picture")
PictureService = sec.Key("SERVICE").In("server", []string{"server"})
@@ -376,7 +382,9 @@ func NewConfigContext() {
DisableGravatar = true
}
- if err = Cfg.Section("git").MapTo(&Git); err != nil {
+ if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
+ log.Fatal(4, "Fail to map Markdown settings: %v", err)
+ } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
log.Fatal(4, "Fail to map Git settings: %v", err)
} else if Cfg.Section("cron").MapTo(&Cron); err != nil {
log.Fatal(4, "Fail to map Cron settings: %v", err)