summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Fok <foka@debian.org>2016-03-20 04:21:16 +0800
committerAnthony Fok <foka@debian.org>2016-03-20 04:21:16 +0800
commit2c5e4f7640e71d2a193a74e6c41109ec40bc0222 (patch)
tree558fc3278749709c4cc84cb03751e8fc4b70bbea
parent4c4ce552171a20116b128aa4c9b97fe4d3727b83 (diff)
helpers: Support EXTENSION_BACKSLASH_LINE_BREAK for Blackfriday
Exposed as "backslashLineBreak" and enabled by default as upstream have done. Fixes #1935
-rw-r--r--helpers/content.go26
-rw-r--r--helpers/content_test.go6
2 files changed, 25 insertions, 7 deletions
diff --git a/helpers/content.go b/helpers/content.go
index 0265a1b51..d67514db2 100644
--- a/helpers/content.go
+++ b/helpers/content.go
@@ -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
diff --git a/helpers/content_test.go b/helpers/content_test.go
index daba018d8..d16f1d660 100644
--- a/helpers/content_test.go
+++ b/helpers/content_test.go
@@ -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},
}