Add smartDashes flag for Blackfriday
authorAnthony Fok <foka@debian.org>
Wed, 5 Aug 2015 22:39:29 +0000 (16:39 -0600)
committerAnthony Fok <foka@debian.org>
Fri, 30 Oct 2015 19:30:25 +0000 (13:30 -0600)
To allow the end users to disable any form of smart dashes
(LaTeX-style or not) while keeping the rest of Blackfriday
SmartyPants features.

Depends on https://github.com/russross/blackfriday/pull/190
"Add HTML_SMARTYPANTS_DASHES for toggling smart dashes"
to be accepted by Blackfriday developers.

docs/content/overview/configuration.md
helpers/content.go

index 2a3f16f0bfb1a532ab5258a6dda08308df243be0..95727f530f1ec4b2e86814a67a22b86b92446ff5 100644 (file)
@@ -179,7 +179,7 @@ But Hugo does expose some options---as listed in the table below, matched with t
 <tr>
 <td class="purpose-title">Purpose:</td>
 <td class="purpose-description" colspan="2">Enable/Disable smart punctuation substitutions such as smart quotes, smart dashes, etc.
-May be fine-tuned with the <code>angledQuotes</code>, <code>fractions</code> and <code>latexDashes</code> flags below.</td>
+May be fine-tuned with the <code>angledQuotes</code>, <code>fractions</code>, <code>smartDashes</code> and <code>latexDashes</code> flags below.</td>
 </tr>
 
 <tr>
@@ -208,6 +208,17 @@ Blackfriday would still convert 1/2, 1/4 and 3/4 to ½&nbsp;(<code>&amp;frac12;<
 but only these three.</small></td>
 </tr>
 
+<tr>
+<td><code><strong>smartDashes</strong></code></td>
+<td><code>true</code></td>
+<td><code>HTML_SMARTYPANTS_DASHES</code></td>
+</tr>
+<tr>
+<td class="purpose-title">Purpose:</td>
+<td class="purpose-description" colspan="2">Enable/Disable smart dashes, i.e. turning hyphens into en&nbsp;dash or em&nbsp;dash.<br>
+Its behavior can be modified with the <code>latexDashes</code> flag listed below.</td>
+</tr>
+
 <tr>
 <td><code><strong>latexDashes</strong></code></td>
 <td><code>true</code></td>
index 847d4dcbc28003175255fd37dd80eabe09bb0a12..b42efaefe6e0a31fb87b6223403760574cdbc684 100644 (file)
@@ -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
        }