Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions kibble/models/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 8 additions & 0 deletions kibble/models/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ func TestMarkdownContent(t *testing.T) {
ConfigureShortcodeTemplatePath(cfg)
assert.Equal(t, "<h1>ONE</h1>\n", ApplyContentTransforms("# ONE"))
}

func TestMarkdownWithCRLFEndings(t *testing.T) {
// blackfriday doesn't automatically handle \r\n line endings so we convert
// to \n first.
ConfigureShortcodeTemplatePath(cfg)
assert.Equal(t, "<h1>ONE</h1>\n\n<p>Paragraph 1</p>\n\n<p>Paragraph 2</p>\n", ApplyContentTransforms("# ONE\r\n\r\nParagraph 1\r\n\r\nParagraph 2"))
}

func TestEchoEmbeddedTemplateContent(t *testing.T) {
ConfigureShortcodeTemplatePath(cfg)
assert.Equal(t,
Expand Down
Loading