Skip to content

Commit

Permalink
add a note about windows line endings to readme.md (for #154)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Sep 18, 2021
1 parent d46797e commit 34eadb9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ maybeUnsafeHTML := markdown.ToHTML(md, nil, nil)
html := bluemonday.UGCPolicy().SanitizeBytes(maybeUnsafeHTML)
```

## Windows / Mac newlines

The library only supports Unix newlines. If you have markdown text with possibly
Windows / Mac newlines, normalize newlines before caling this library. Use function like:

```go
func normalizeNewlines(s string) string {
// replace CR LF (windows) with LF (unix)
s = strings.Replace(s, string([]byte{13, 10}), "\n", -1)
// replace CF (mac) with LF (unix)
s = strings.Replace(s, string([]byte{13}), "\n", -1)
return s
}
```

## mdtohtml command-line tool

https://github.com/gomarkdown/mdtohtml is a command-line markdown to html
Expand Down

0 comments on commit 34eadb9

Please sign in to comment.