Skip to content

Commit 553d0a1

Browse files
committed
Add CRLF support
1 parent ad538e9 commit 553d0a1

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/Blog/Page/HtmlTemplatedMarkdownFile.cs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ private async Task<string> GenerateHtmlAsync(CancellationToken cancellationToken
140140
return (string.Empty, text);
141141
}
142142

143-
// Find the closing delimiter
144-
var lines = text.Split(new[] { '\r', '\n' }, StringSplitOptions.None);
143+
// Find the closing delimiter. Split on whole newline sequences so CRLF input
144+
// doesn't create blank lines between every Markdown line.
145+
var lines = text.Split(new[] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
146+
145147
var closingDelimiterIndex = -1;
146148

147149
for (int i = 1; i < lines.Length; i++)
@@ -187,6 +189,7 @@ protected virtual string TransformMarkdownToHtml(string markdown)
187189
return Markdown.ToHtml(markdown, pipeline);
188190
}
189191

192+
190193
/// <summary>
191194
/// Parse YAML front-matter string to arbitrary dictionary.
192195
/// No schema enforcement - accepts any valid YAML structure.
@@ -276,4 +279,4 @@ protected virtual async Task<string> RenderTemplateAsync(IFile templateFile, Htm
276279
return template.Render(model);
277280
}
278281
}
279-
}
282+
}

0 commit comments

Comments
 (0)