[Question] TextWriter.NewLine is hard-coded to '\n' even when running on Windows #194

Closed
opened 2026-01-29 14:30:05 +00:00 by claunia · 3 comments
Owner

Originally created by @augustoproiete on GitHub (Feb 20, 2018).

Hello!

Quick question: Is there a reason to always uses \n for line-breaks instead of Environment.NewLine, or is just preference?

Markdown files will typically contain fragments of content that - after being converted to HTML - are likely added as content to an HTML template (which itself has line-breaks), which can cause mixed line-endings if the HTML template uses \r\n.

Originally created by @augustoproiete on GitHub (Feb 20, 2018). Hello! Quick question: Is there a reason to [always uses `\n` for line-breaks instead of `Environment.NewLine`](https://github.com/lunet-io/markdig/blob/master/src/Markdig/Renderers/TextRendererBase.cs#L32), or is just preference? Markdown files will typically contain fragments of content that - after being converted to HTML - are likely added as content to an HTML template (which itself has line-breaks), which can cause mixed line-endings if the HTML template uses `\r\n`.
claunia added the enhancementPR Welcome! labels 2026-01-29 14:30:05 +00:00
Author
Owner

@Kryptos-FR commented on GitHub (Feb 20, 2018):

This should probably be an option (with a decent default value, like Environment.NewLine) so as to accommodate all scenarios.

@Kryptos-FR commented on GitHub (Feb 20, 2018): This should probably be an option (with a decent default value, like `Environment.NewLine`) so as to accommodate all scenarios.
Author
Owner

@augustoproiete commented on GitHub (Feb 21, 2018):

@Kryptos-FR I agree that this should be configurable. I've submitted PR #214 to address that.

I'm curious on why Environment.NewLine is not the default, though...

@augustoproiete commented on GitHub (Feb 21, 2018): @Kryptos-FR I agree that this should be configurable. I've submitted PR #214 to address that. I'm curious on why `Environment.NewLine` is not the default, though...
Author
Owner

@xoofx commented on GitHub (Apr 4, 2018):

Thanks, PR #214 is merged, will publish a new package soon

@xoofx commented on GitHub (Apr 4, 2018): Thanks, PR #214 is merged, will publish a new package soon
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#194