hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 75904332f3bedcfe656856821d4c9560a177cc51
parent 60c0eb4e892baedd533424b47baf7039c0005f87
Author: arrtchiu <arrtchiu@gmail.com>
Date:   Mon,  4 Mar 2019 18:27:18 +0800

Add skipHTML option to blackfriday config


Diffstat:
Mdocs/content/en/readfiles/bfconfig.md | 5+++++
Mhelpers/content.go | 6++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/docs/content/en/readfiles/bfconfig.md b/docs/content/en/readfiles/bfconfig.md
@@ -71,6 +71,11 @@
     Example: Include `autoHeaderIds` as `false` in the list to disable Blackfriday's `EXTENSION_AUTO_HEADER_IDS`. <br>
     *See [Blackfriday extensions](#blackfriday-extensions) section for information on all extensions.*
 
+`skipHTML`
+: default: **`false`** <br>
+    Blackfriday flag: **`HTML_SKIP_HTML`** <br>
+    Purpose: `true` causes any HTML in the markdown files to be skipped.
+
 ## Blackfriday extensions
 
 `noIntraEmphasis`
diff --git a/helpers/content.go b/helpers/content.go
@@ -119,6 +119,7 @@ type BlackFriday struct {
 	PlainIDAnchors        bool
 	Extensions            []string
 	ExtensionsMask        []string
+	SkipHTML              bool
 }
 
 // NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults.
@@ -135,6 +136,7 @@ func newBlackfriday(config map[string]interface{}) *BlackFriday {
 		"latexDashes":           true,
 		"plainIDAnchors":        true,
 		"taskLists":             true,
+		"skipHTML":              false,
 	}
 
 	maps.ToLower(defaultParam)
@@ -300,6 +302,10 @@ func (c *ContentSpec) getHTMLRenderer(defaultFlags int, ctx *RenderingContext) b
 		htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
 	}
 
+	if ctx.Config.SkipHTML {
+		htmlFlags |= blackfriday.HTML_SKIP_HTML
+	}
+
 	return &HugoHTMLRenderer{
 		cs:               c,
 		RenderingContext: ctx,