diff --git a/commands/hugo.go b/commands/hugo.go index 7aaa0dde6..f57a7c910 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -136,7 +136,7 @@ func InitializeConfig() { viper.SetDefault("FootnoteAnchorPrefix", "") viper.SetDefault("FootnoteReturnLinkContents", "") viper.SetDefault("NewContentEditor", "") - viper.SetDefault("Blackfriday", map[string]bool{"angledQuotes": false, "plainIdAnchors": false}) + viper.SetDefault("Blackfriday", map[string]bool{"angledQuotes": false, "fractions": true, "plainIdAnchors": false}) if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed { viper.Set("BuildDrafts", Draft) diff --git a/docs/content/overview/configuration.md b/docs/content/overview/configuration.md index 4e4b750c1..a07ef5672 100644 --- a/docs/content/overview/configuration.md +++ b/docs/content/overview/configuration.md @@ -91,6 +91,21 @@ But Hugo does expose some options---as listed in the table below, matched with t Enable smart angled double quotes (e.g. "Hugo" renders to «Hugo» instead of “Hugo”) + +fractions +true +HTML_SMARTYPANTS_FRACTIONS + + +Purpose: +Enable smart fractions +(e.g. 5/12 renders to 512 (<sup>5</sup>&frasl;<sub>12</sub>)) +Caveat: Even with fractions = false, +Blackfriday would still convert 1/2, 1/4 and 3/4 to ½ (&frac12;), +¼ (&frac14;) and ¾ (&frac34;) respectively, +but only these three. + + plainIdAnchors false @@ -112,11 +127,13 @@ But Hugo does expose some options---as listed in the table below, matched with t
[blackfriday]
-    angledQuotes = true
-    plainIdAnchors = true
+  angledQuotes = true
+  fractions = false
+  plainIdAnchors = true
 
blackfriday:
   angledQuotes: true
+  fractions: false
   plainIdAnchors: true
 
diff --git a/helpers/content.go b/helpers/content.go index 1d051801d..4f378c82b 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -95,11 +95,10 @@ func GetHtmlRenderer(defaultFlags int, ctx RenderingContext) blackfriday.Rendere htmlFlags := defaultFlags htmlFlags |= blackfriday.HTML_USE_XHTML htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS - htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES htmlFlags |= blackfriday.HTML_FOOTNOTE_RETURN_LINKS - var angledQuotes bool + var angledQuotes, fractions bool if m, ok := ctx.ConfigFlags["angledQuotes"]; ok { angledQuotes = m @@ -109,6 +108,14 @@ func GetHtmlRenderer(defaultFlags int, ctx RenderingContext) blackfriday.Rendere htmlFlags |= blackfriday.HTML_SMARTYPANTS_ANGLED_QUOTES } + if m, ok := ctx.ConfigFlags["fractions"]; ok { + fractions = m + } + + if fractions { + htmlFlags |= blackfriday.HTML_SMARTYPANTS_FRACTIONS + } + return blackfriday.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters) }