Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle newlines and missing titles #20

Merged
merged 3 commits into from
Jul 10, 2013
Merged

Properly handle newlines and missing titles #20

merged 3 commits into from
Jul 10, 2013

Conversation

heptal
Copy link
Contributor

@heptal heptal commented Jul 9, 2013

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.

The 2 followup commits allow you to add other markdown files without proper titles to jingo, as in the case of migrating from gollum. This is accomplished by checking for a jingo-formatted title line, making sure the first line of content does not get clobbered when editing, and using the filename for a title where appropriate. Subsequent edits prepend the jingo-formatted title to the file if necessary while staying compatible with other tools.

@claudioc
Copy link
Owner

That's great, very nice stuff. I already had an issue about line endings normalizing (I was aware of the problem). Two birds with a stone!

And I did not think about eventually importing data from other systems.

Thank you very much!

claudioc added a commit that referenced this pull request Jul 10, 2013
Properly handle newlines and missing titles
@claudioc claudioc merged commit 3aa5b1d into claudioc:master Jul 10, 2013
yusiwen added a commit to yusiwen/jingo that referenced this pull request Dec 16, 2016
Adjust layout for sidebar toggle

Fixes claudioc#20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants