mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
helpers: Support EXTENSION_BACKSLASH_LINE_BREAK for Blackfriday
Exposed as "backslashLineBreak" and enabled by default as upstream have done. Fixes #1935
This commit is contained in:
parent
4c4ce55217
commit
2c5e4f7640
2 changed files with 25 additions and 7 deletions
|
@ -55,7 +55,7 @@ type Blackfriday struct {
|
|||
ExtensionsMask []string
|
||||
}
|
||||
|
||||
// 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.
|
||||
func NewBlackfriday() *Blackfriday {
|
||||
combinedParam := map[string]interface{}{
|
||||
"smartypants": true,
|
||||
|
@ -100,6 +100,7 @@ var blackfridayExtensionMap = map[string]int{
|
|||
"headerIds": blackfriday.EXTENSION_HEADER_IDS,
|
||||
"titleblock": blackfriday.EXTENSION_TITLEBLOCK,
|
||||
"autoHeaderIds": blackfriday.EXTENSION_AUTO_HEADER_IDS,
|
||||
"backslashLineBreak": blackfriday.EXTENSION_BACKSLASH_LINE_BREAK,
|
||||
"definitionLists": blackfriday.EXTENSION_DEFINITION_LISTS,
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ func BytesToHTML(b []byte) template.HTML {
|
|||
return template.HTML(string(b))
|
||||
}
|
||||
|
||||
// getHTMLRenderer creates a new Renderer with the given configuration.
|
||||
// getHTMLRenderer creates a new Blackfriday HTML Renderer with the given configuration.
|
||||
func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Renderer {
|
||||
renderParameters := blackfriday.HtmlRendererParameters{
|
||||
FootnoteAnchorPrefix: viper.GetString("FootnoteAnchorPrefix"),
|
||||
|
@ -207,12 +208,23 @@ func getHTMLRenderer(defaultFlags int, ctx *RenderingContext) blackfriday.Render
|
|||
}
|
||||
|
||||
func getMarkdownExtensions(ctx *RenderingContext) int {
|
||||
flags := 0 | blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
|
||||
blackfriday.EXTENSION_TABLES | blackfriday.EXTENSION_FENCED_CODE |
|
||||
blackfriday.EXTENSION_AUTOLINK | blackfriday.EXTENSION_STRIKETHROUGH |
|
||||
blackfriday.EXTENSION_SPACE_HEADERS | blackfriday.EXTENSION_FOOTNOTES |
|
||||
blackfriday.EXTENSION_HEADER_IDS | blackfriday.EXTENSION_AUTO_HEADER_IDS |
|
||||
// Default Blackfriday common extensions
|
||||
commonExtensions := 0 |
|
||||
blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
|
||||
blackfriday.EXTENSION_TABLES |
|
||||
blackfriday.EXTENSION_FENCED_CODE |
|
||||
blackfriday.EXTENSION_AUTOLINK |
|
||||
blackfriday.EXTENSION_STRIKETHROUGH |
|
||||
blackfriday.EXTENSION_SPACE_HEADERS |
|
||||
blackfriday.EXTENSION_HEADER_IDS |
|
||||
blackfriday.EXTENSION_BACKSLASH_LINE_BREAK |
|
||||
blackfriday.EXTENSION_DEFINITION_LISTS
|
||||
|
||||
// Extra Blackfriday extensions that Hugo enables by default
|
||||
flags := commonExtensions |
|
||||
blackfriday.EXTENSION_AUTO_HEADER_IDS |
|
||||
blackfriday.EXTENSION_FOOTNOTES
|
||||
|
||||
for _, extension := range ctx.getConfig().Extensions {
|
||||
if flag, ok := blackfridayExtensionMap[extension]; ok {
|
||||
flags |= flag
|
||||
|
|
|
@ -244,10 +244,16 @@ func TestGetMarkdownExtensionsByDefaultAllExtensionsAreEnabled(t *testing.T) {
|
|||
{blackfriday.EXTENSION_FENCED_CODE},
|
||||
{blackfriday.EXTENSION_AUTOLINK},
|
||||
{blackfriday.EXTENSION_STRIKETHROUGH},
|
||||
// {blackfriday.EXTENSION_LAX_HTML_BLOCKS},
|
||||
{blackfriday.EXTENSION_SPACE_HEADERS},
|
||||
// {blackfriday.EXTENSION_HARD_LINE_BREAK},
|
||||
// {blackfriday.EXTENSION_TAB_SIZE_EIGHT},
|
||||
{blackfriday.EXTENSION_FOOTNOTES},
|
||||
// {blackfriday.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK},
|
||||
{blackfriday.EXTENSION_HEADER_IDS},
|
||||
// {blackfriday.EXTENSION_TITLEBLOCK},
|
||||
{blackfriday.EXTENSION_AUTO_HEADER_IDS},
|
||||
{blackfriday.EXTENSION_BACKSLASH_LINE_BREAK},
|
||||
{blackfriday.EXTENSION_DEFINITION_LISTS},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue