mirror of https://github.com/gogs/gogs.git
markdown: support Smartypants (#4162)
Added new config section '[smartypants]', and disabled by default.pull/4280/head
parent
31c55213ff
commit
ac8b1e595f
|
@ -124,6 +124,13 @@ CUSTOM_URL_SCHEMES =
|
|||
; Separate extensions with a comma. To render files w/o extension as markdown, just put a comma
|
||||
FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
|
||||
|
||||
[smartypants]
|
||||
ENABLED = false
|
||||
FRACTIONS = true
|
||||
DASHES = true
|
||||
LATEX_DASHES = true
|
||||
ANGLED_QUOTES = true
|
||||
|
||||
[http]
|
||||
; Value for Access-Control-Allow-Origin header, default is not to present
|
||||
ACCESS_CONTROL_ALLOW_ORIGIN =
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.10.13.0310"
|
||||
const APP_VER = "0.10.14.0310"
|
||||
|
||||
func init() {
|
||||
setting.AppVer = APP_VER
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -294,6 +294,23 @@ func RenderRaw(body []byte, urlPrefix string) []byte {
|
|||
htmlFlags := 0
|
||||
htmlFlags |= blackfriday.HTML_SKIP_STYLE
|
||||
htmlFlags |= blackfriday.HTML_OMIT_CONTENTS
|
||||
|
||||
if setting.Smartypants.Enabled {
|
||||
htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
|
||||
if setting.Smartypants.Fractions {
|
||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS
|
||||
}
|
||||
if setting.Smartypants.Dashes {
|
||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_DASHES
|
||||
}
|
||||
if setting.Smartypants.LatexDashes {
|
||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
|
||||
}
|
||||
if setting.Smartypants.AngledQuotes {
|
||||
htmlFlags |= blackfriday.HTML_SMARTYPANTS_ANGLED_QUOTES
|
||||
}
|
||||
}
|
||||
|
||||
renderer := &Renderer{
|
||||
Renderer: blackfriday.HtmlRenderer(htmlFlags, "", ""),
|
||||
urlPrefix: urlPrefix,
|
||||
|
|
|
@ -153,6 +153,15 @@ var (
|
|||
FileExtensions []string
|
||||
}
|
||||
|
||||
// Smartypants settings
|
||||
Smartypants struct {
|
||||
Enabled bool
|
||||
Fractions bool
|
||||
Dashes bool
|
||||
LatexDashes bool
|
||||
AngledQuotes bool
|
||||
}
|
||||
|
||||
// Admin settings
|
||||
Admin struct {
|
||||
DisableRegularOrgCreation bool
|
||||
|
@ -583,6 +592,8 @@ func NewContext() {
|
|||
log.Fatal(2, "Fail to map Webhook settings: %v", err)
|
||||
} else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
|
||||
log.Fatal(2, "Fail to map Markdown settings: %v", err)
|
||||
} else if err = Cfg.Section("smartypants").MapTo(&Smartypants); err != nil {
|
||||
log.Fatal(2, "Fail to map Smartypants settings: %v", err)
|
||||
} else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
|
||||
log.Fatal(2, "Fail to map Admin settings: %v", err)
|
||||
} else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.10.13.0310
|
||||
0.10.14.0310
|
Loading…
Reference in New Issue