Add skipHTML option to blackfriday config

This commit is contained in:
arrtchiu 2019-03-04 18:27:18 +08:00 committed by Bjørn Erik Pedersen
parent 60c0eb4e89
commit 75904332f3
2 changed files with 11 additions and 0 deletions

View file

@ -71,6 +71,11 @@
Example: Include `autoHeaderIds` as `false` in the list to disable Blackfriday's `EXTENSION_AUTO_HEADER_IDS`. <br> 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.* *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 ## Blackfriday extensions
`noIntraEmphasis` `noIntraEmphasis`

View file

@ -119,6 +119,7 @@ type BlackFriday struct {
PlainIDAnchors bool PlainIDAnchors bool
Extensions []string Extensions []string
ExtensionsMask []string ExtensionsMask []string
SkipHTML bool
} }
// NewBlackfriday creates a new Blackfriday filled with site config or some sane defaults. // 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, "latexDashes": true,
"plainIDAnchors": true, "plainIDAnchors": true,
"taskLists": true, "taskLists": true,
"skipHTML": false,
} }
maps.ToLower(defaultParam) maps.ToLower(defaultParam)
@ -300,6 +302,10 @@ func (c *ContentSpec) getHTMLRenderer(defaultFlags int, ctx *RenderingContext) b
htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES htmlFlags |= blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
} }
if ctx.Config.SkipHTML {
htmlFlags |= blackfriday.HTML_SKIP_HTML
}
return &HugoHTMLRenderer{ return &HugoHTMLRenderer{
cs: c, cs: c,
RenderingContext: ctx, RenderingContext: ctx,