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

Replace fails in file with mixed line endings #22

Closed
ghost23 opened this issue Jan 15, 2015 · 8 comments
Closed

Replace fails in file with mixed line endings #22

ghost23 opened this issue Jan 15, 2015 · 8 comments

Comments

@ghost23
Copy link
Contributor

ghost23 commented Jan 15, 2015

Hi,

when I have a file, that generally has LF line endings, but for some reason, there
are also some CRLF line endings, then htmlreplace does not replace anything in the file.

@VFK
Copy link
Owner

VFK commented Jan 15, 2015

Ugh line endings again... Could you please provide this odd file so i can fix it once and for all?

@ghost23
Copy link
Contributor Author

ghost23 commented Jan 15, 2015

Sure,

but how should I do that? It seems, i cannot attach it here.

@bmacnaughton
Copy link
Contributor

Would splitting lines based on \n only (completely ignore \r) be the right approach here? If you do that the \r, if it's present, would just be part of the line. And you can handle any mixture of \n or \r\n lines. I don't think there is any need to actually test for \r\n.

@VFK
Copy link
Owner

VFK commented Jan 15, 2015

@ghost23 Maybe Dropbox, Google Drive worked pretty well in this comment too: #19 (comment) Any file sharing thing basically. Thank you.

@bmacnaughton It might work, but there may be some weird problems in rare cases. I better look at that file and run some tests before i do anything about it.

@ghost23
Copy link
Contributor Author

ghost23 commented Jan 15, 2015

@bmacnaughton
Copy link
Contributor

I think it works OK but you do have to make a decision on line 26 about what linefeed sequence to insert.

It wouldn't handle OLD Mac files with a \r line separator, but I don't think that really matters any longer.

@VFK
Copy link
Owner

VFK commented Jan 17, 2015

@bmacnaughton I'm using split by \n, this seems to be working ok, thanks for the idea. I think i better modify the code to not do "split" at all, but this is something for the future releases.

@ghost23, @charlescaron i've added your files to the "test" folder. I couldn't ask for a permission, there is no such thing as private messages on github, but if you're not ok with this (maybe those files are from some super-secret project or something) then please open an issue and i'll remove them.

@VFK VFK closed this as completed Jan 17, 2015
@bmacnaughton
Copy link
Contributor

Thanks for the note. I think you're right - no split at all would be better but that's a bigger change. The history of line endings still makes life complicated.

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

No branches or pull requests

3 participants