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

Alternative Newline Characters #260

Closed
manngo opened this issue May 8, 2013 · 11 comments
Closed

Alternative Newline Characters #260

manngo opened this issue May 8, 2013 · 11 comments

Comments

@manngo
Copy link

manngo commented May 8, 2013

Secondly, it appears that when jsBeautifier adds new line, it is always with the '\n' character. Is it possible to allow for the windows style '\r\n' newline? I thought I had found where the new line is created, but it seems to break the indentation. Here is what I tried:

// Somewhere around line 170:
opt.eol = options.eol ? options.eol : '\n'; // a new option

// Somewhere around line 370, change to:
if (force_newline || !just_added_newline()) {
output.push(opt.eol); // was output.push("\n");
}

… but I find that if opt.eol is anything other than '\n' all of the tabs get through away.

Thanks,

Mark

@bitwiseman
Copy link
Member

You have a good starting idea. You need to modify just_added_newline() to check for opt.eol. There might be other gotchas but that is the first thing I can think of.

@bitwiseman
Copy link
Member

FYI, it seems this is may not be an issue on python: jdavisclark/JsFormat#65

@bitwiseman
Copy link
Member

Ah, and on nodejs we can use os.eol.

@jayfang
Copy link

jayfang commented Aug 1, 2013

BTW on Windows Git makes a complaint (as below) about every beautified file

warning: LF will be replaced by CRLF in myNowBeautifulFile.js.
The file will have its original line endings in your working directory.

AFAICT Git expects to see the OS eol marker. Manually resetting CRLF in my editor is fast, but it still makes beautification a bit 'noisy' in my workflow.

bitwiseman added a commit that referenced this issue Oct 11, 2013
When running in node, use os.eol to choose line endings - windows will use \r\n, linux will use \n.

Fixes #260
@bitwiseman bitwiseman reopened this Oct 11, 2013
@bitwiseman
Copy link
Member

Nope, that didn't work at all. This is going to be a breaking change of some kind. Pushing to next milestone.

@sethflowers
Copy link

+1 - unable to incorporate this into our teams workflow due to forcing \n as newline character.

@gabrielmaldi
Copy link
Contributor

Would it be possible to release a version with this change before v1.6.0? I realize it may well be a breaking change, but I fear it will be too long until v1.6.0 is released (there are a lot of open issues) and we need this so that grunt-jsbeautifier can target it.
Thanks!

@bitwiseman
Copy link
Member

Sure, I can do that.

@corgrath
Copy link

corgrath commented May 5, 2015

+1 on @gabrielmaldi 's suggestion

It would be fantastic if the eol option could come in before 1.6.0, as it is the only bug that currently breaks our code and prevents us from using grunt-jsbeautifier/jsbeautify :-)

@mahboob-awan
Copy link

@corgrath +1

@bitwiseman bitwiseman modified the milestones: v1.6.0, v1.5.6 May 6, 2015
@gabrielmaldi
Copy link
Contributor

I've tried this new feature and it works fine 👍 However, I think I found a bug which I reported in #781.

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

No branches or pull requests

7 participants