ref: 4a2eda49cdd3180ab884a696ac987d7d6bb375db
parent: eb519afefdd506de46968f598fe78af7cda49dee
author: Anthony Fok <[email protected]>
date: Tue Aug 4 09:05:48 EDT 2015
Add option to disable Blackfriday Smartypants Can be used in site config or per page front matter: ``` [blackfriday] smartypants = false ```
--- a/docs/content/overview/configuration.md
+++ b/docs/content/overview/configuration.md
@@ -166,6 +166,16 @@
<tbody>
<tr>
+<td><code><strong>smartypants</strong></code></td>
+<td><code>true</code></td>
+<td><code>HTML_USE_SMARTYPANTS</code></td>
+</tr>
+<tr>
+<td class="purpose-title">Purpose:</td>
+<td class="purpose-description" colspan="2">Enable enable smart punctuation substitutions.</td>
+</tr>
+
+<tr>
<td><code><strong>angledQuotes</strong></code></td>
<td><code>false</code></td>
<td><code>HTML_SMARTYPANTS_ANGLED_QUOTES</code></td>
@@ -191,23 +201,25 @@
</tr>
<tr>
-<td><code><strong>hrefTargetBlank</strong></code></td>
-<td><code>false</code></td>
-<td><code>HTML_HREF_TARGET_BLANK</code></td>
+<td><code><strong>latexDashes</strong></code></td>
+<td><code>true</code></td>
+<td><code>HTML_SMARTYPANTS_LATEX_DASHES</code></td>
</tr>
<tr>
<td class="purpose-title">Purpose:</td>
-<td class="purpose-description" colspan="2">Open external links in a new window/tab.</small></td>
+<td class="purpose-description" colspan="2">Disable LaTeX style dashes.</small></td>
</tr>
+<tr style="height: 0.3em;"></tr>
+
<tr>
-<td><code><strong>latexDashes</strong></code></td>
-<td><code>true</code></td>
-<td><code>HTML_SMARTYPANTS_LATEX_DASHES</code></td>
+<td><code><strong>hrefTargetBlank</strong></code></td>
+<td><code>false</code></td>
+<td><code>HTML_HREF_TARGET_BLANK</code></td>
</tr>
<tr>
<td class="purpose-title">Purpose:</td>
-<td class="purpose-description" colspan="2">Disable LaTeX style dashes.</small></td>
+<td class="purpose-description" colspan="2">Open external links in a new window/tab.</small></td>
</tr>
<tr>
@@ -219,6 +231,8 @@
<td class="purpose-title">Purpose:</td>
<td class="purpose-description" colspan="2">If <code>true</code>, then header and footnote IDs are generated without the document ID <small>(e.g. <code>#my-header</code> instead of <code>#my-header:bec3ed8ba720b9073ab75abcf3ba5d97</code>)</small></td>
</tr>
+
+<tr style="height: 0.3em;"></tr>
<tr>
<td><code><strong>extensions</strong></code></td>
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -40,6 +40,7 @@
// Blackfriday holds configuration values for Blackfriday rendering.
type Blackfriday struct {
+ Smartypants bool
AngledQuotes bool
Fractions bool
HrefTargetBlank bool
@@ -52,6 +53,7 @@
// NewBlackfriday creates a new Blackfriday with some sane defaults.
func NewBlackfriday() *Blackfriday {
return &Blackfriday{
+ Smartypants: true,
AngledQuotes: false,
Fractions: true,
HrefTargetBlank: false,
@@ -148,8 +150,11 @@
htmlFlags := defaultFlags
htmlFlags |= blackfriday.HTML_USE_XHTML
- htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
htmlFlags |= blackfriday.HTML_FOOTNOTE_RETURN_LINKS
+
+ if ctx.getConfig().Smartypants {
+ htmlFlags |= blackfriday.HTML_USE_SMARTYPANTS
+ }
if ctx.getConfig().AngledQuotes {
htmlFlags |= blackfriday.HTML_SMARTYPANTS_ANGLED_QUOTES