mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Add option to disable Blackfriday Smartypants
Can be used in site config or per page front matter: ``` [blackfriday] smartypants = false ```
This commit is contained in:
parent
eb519afefd
commit
4a2eda49cd
2 changed files with 30 additions and 11 deletions
|
@ -165,6 +165,16 @@ But Hugo does expose some options---as listed in the table below, matched with t
|
|||
</thead>
|
||||
|
||||
<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>
|
||||
|
@ -190,16 +200,6 @@ Blackfriday would still convert 1/2, 1/4 and 3/4 to ½ (<code>&frac12;<
|
|||
but only these three.</small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<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">Open external links in a new window/tab.</small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code><strong>latexDashes</strong></code></td>
|
||||
<td><code>true</code></td>
|
||||
|
@ -210,6 +210,18 @@ but only these three.</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>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">Open external links in a new window/tab.</small></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><code><strong>plainIdAnchors</strong></code></td>
|
||||
<td><code>false</code></td>
|
||||
|
@ -220,6 +232,8 @@ but only these three.</small></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>
|
||||
<td><code>[]</code></td>
|
||||
|
|
|
@ -40,6 +40,7 @@ var SummaryDivider = []byte("<!--more-->")
|
|||
|
||||
// Blackfriday holds configuration values for Blackfriday rendering.
|
||||
type Blackfriday struct {
|
||||
Smartypants bool
|
||||
AngledQuotes bool
|
||||
Fractions bool
|
||||
HrefTargetBlank bool
|
||||
|
@ -52,6 +53,7 @@ type Blackfriday struct {
|
|||
// NewBlackfriday creates a new Blackfriday with some sane defaults.
|
||||
func NewBlackfriday() *Blackfriday {
|
||||
return &Blackfriday{
|
||||
Smartypants: true,
|
||||
AngledQuotes: false,
|
||||
Fractions: true,
|
||||
HrefTargetBlank: false,
|
||||
|
@ -148,9 +150,12 @@ func GetHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Render
|
|||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue