shithub: hugo

Download patch

ref: e95db67b20163c8ab43f4a652b9b6dc7dc13a230
parent: 6b34a4e4e8a18e1f78a5727e583638a6bb247f4f
author: Anthony Fok <[email protected]>
date: Wed Aug 5 12:39:29 EDT 2015

Add smartDashes flag for Blackfriday

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.

--- a/docs/content/overview/configuration.md
+++ b/docs/content/overview/configuration.md
@@ -179,7 +179,7 @@
 <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>
@@ -206,6 +206,17 @@
 Blackfriday would still convert 1/2, 1/4 and 3/4 to ½&nbsp;(<code>&amp;frac12;</code>),
 ¼&nbsp;(<code>&amp;frac14;</code>) and ¾&nbsp;(<code>&amp;frac34;</code>) respectively,
 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>
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -45,6 +45,7 @@
 	AngledQuotes    bool
 	Fractions       bool
 	HrefTargetBlank bool
+	SmartDashes     bool
 	LatexDashes     bool
 	PlainIDAnchors  bool
 	Extensions      []string
@@ -58,6 +59,7 @@
 		AngledQuotes:    false,
 		Fractions:       true,
 		HrefTargetBlank: false,
+		SmartDashes:     true,
 		LatexDashes:     true,
 		PlainIDAnchors:  false,
 	}
@@ -167,6 +169,10 @@
 
 	if ctx.getConfig().HrefTargetBlank {
 		htmlFlags |= blackfriday.HTML_HREF_TARGET_BLANK
+	}
+
+	if ctx.getConfig().SmartDashes {
+		htmlFlags |= blackfriday.HTML_SMARTYPANTS_DASHES
 	}
 
 	if ctx.getConfig().LatexDashes {