diff --git a/docs/content/overview/configuration.md b/docs/content/overview/configuration.md index 2a3f16f0b..95727f530 100644 --- a/docs/content/overview/configuration.md +++ b/docs/content/overview/configuration.md @@ -179,7 +179,7 @@ But Hugo does expose some options---as listed in the table below, matched with t Purpose: Enable/Disable smart punctuation substitutions such as smart quotes, smart dashes, etc. -May be fine-tuned with the angledQuotes, fractions and latexDashes flags below. +May be fine-tuned with the angledQuotes, fractions, smartDashes and latexDashes flags below. @@ -208,6 +208,17 @@ Blackfriday would still convert 1/2, 1/4 and 3/4 to ½ (&frac12;< but only these three. + +smartDashes +true +HTML_SMARTYPANTS_DASHES + + +Purpose: +Enable/Disable smart dashes, i.e. turning hyphens into en dash or em dash.
+Its behavior can be modified with the latexDashes flag listed below. + + latexDashes true diff --git a/helpers/content.go b/helpers/content.go index 847d4dcbc..b42efaefe 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -45,6 +45,7 @@ type Blackfriday struct { AngledQuotes bool Fractions bool HrefTargetBlank bool + SmartDashes bool LatexDashes bool PlainIDAnchors bool Extensions []string @@ -58,6 +59,7 @@ func NewBlackfriday() *Blackfriday { AngledQuotes: false, Fractions: true, HrefTargetBlank: false, + SmartDashes: true, LatexDashes: true, PlainIDAnchors: false, } @@ -169,6 +171,10 @@ func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Render htmlFlags |= blackfriday.HTML_HREF_TARGET_BLANK } + if ctx.getConfig().SmartDashes { + htmlFlags |= blackfriday.HTML_SMARTYPANTS_DASHES + } + if ctx.getConfig().LatexDashes { htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES }