claudioc/jingo — pull request #20 by heptal (2013-07-09 08:40:56+00:00)
Title: Properly handle newlines

Textareas can return their content with DOS-style `\r\n` line endings. This happens in Chrome on OSX, among many other browsers and platforms. This makes the `.md` files rather cumbersome to work with in vim and other tools.

When editing, jingo currently splits the file content on `\n` newlines and then joins them again to a single blob. This loses existing newline data for `.md` files which use `\n`-style line endings, which happens to be most of them. Try editing README.md for an example.

This commit converts all line endings to `\n` on creation or the next edit of an existing file, preserving all newlines. It also allows jingo to properly edit existing Unix-style markdown files by less-destructively reading the file input.