Browse Source

markdown: support Smartypants (#4162)

Added new config section '[smartypants]', and disabled by default.
pull/4280/head
Unknwon 8 years ago
parent
commit
ac8b1e595f
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 7
      conf/app.ini
  2. 2
      gogs.go
  3. 4
      modules/bindata/bindata.go
  4. 17
      modules/markdown/markdown.go
  5. 11
      modules/setting/setting.go
  6. 2
      templates/.VERSION

7
conf/app.ini

@ -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

@ -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

4
modules/bindata/bindata.go

File diff suppressed because one or more lines are too long

17
modules/markdown/markdown.go

@ -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,

11
modules/setting/setting.go

@ -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 {

2
templates/.VERSION

@ -1 +1 @@
0.10.13.0310
0.10.14.0310
Loading…
Cancel
Save