Skip to content

Commit

Permalink
Add skipHTML option to blackfriday config
Browse files Browse the repository at this point in the history
  • Loading branch information
arrtchiu authored and bep committed Mar 4, 2019
1 parent 60c0eb4 commit 7590433
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/content/en/readfiles/bfconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 6 additions & 0 deletions helpers/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -135,6 +136,7 @@ func newBlackfriday(config map[string]interface{}) *BlackFriday {
"latexDashes": true,
"plainIDAnchors": true,
"taskLists": true,
"skipHTML": false,
}

maps.ToLower(defaultParam)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7590433

Please sign in to comment.