diff --git a/changelog.md b/changelog.md index 22e9e2c..382bb86 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ ## [Unreleased] + - Convert CRLF line endings to LF because blackfriday (markdown lib) doesn't + handle them properly + ## [0.17.9] - 2026-01-06 - Add support for 'post' page type diff --git a/kibble/models/template.go b/kibble/models/template.go index 4672210..0f517d5 100644 --- a/kibble/models/template.go +++ b/kibble/models/template.go @@ -205,8 +205,9 @@ func CreateTemplateView(routeRegistry *RouteRegistry, trans i18n.TranslateFunc, // ApplyContentTransforms - add the markdown / sanitization / shortcodes func ApplyContentTransforms(data string) string { - // apply mark down - unsafe := blackfriday.Run([]byte(data)) + // apply mark down. + // note: converting CRLF -> LF due to https://github.com/russross/blackfriday/issues/423 + unsafe := blackfriday.Run([]byte(strings.ReplaceAll(data, "\r\n", "\n"))) // apply the templates return insertTemplates(string(unsafe)) diff --git a/kibble/models/template_test.go b/kibble/models/template_test.go index 1501aee..29d1b14 100644 --- a/kibble/models/template_test.go +++ b/kibble/models/template_test.go @@ -39,6 +39,14 @@ func TestMarkdownContent(t *testing.T) { ConfigureShortcodeTemplatePath(cfg) assert.Equal(t, "
Paragraph 1
\n\nParagraph 2
\n", ApplyContentTransforms("# ONE\r\n\r\nParagraph 1\r\n\r\nParagraph 2")) +} + func TestEchoEmbeddedTemplateContent(t *testing.T) { ConfigureShortcodeTemplatePath(cfg) assert.Equal(t,