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

Encoder generates unneeded indentation and new lines #20

Closed
legendik opened this issue Mar 26, 2015 · 6 comments

Comments

Projects
None yet
2 participants
@legendik
Copy link

commented Mar 26, 2015

Let's have following messagess.neon file:

a:
    b: Some text
    c: Some other text
    d: someKey:
        e: Some next message
f: Hello world

We want to parse this file by Decoder, the decoded values encode by Encoder and save the file back, because we want fix "Neon coding standards" in this file. Like remove unneeded ",' etc...

The common problem is, that the Encoder properly fix the Neon coding standards, but generates also unneeded newlines and tabs.

Let's have following code:

$file = file_get_contents('messages.neon');
$decoder = new Decoder;
$decoded = $decoder->decode($file);
$encoder = new Encoder;
$encoded = $encoder->encode($decoded, Encoder::BLOCK);
file_put_contents('messages.neon', $encoded);

And the result of messages.neon?

a:
    b: Some text
    c: Some other text
    d: someKey:
        e: Some next message
        #two tabs
    #one tab
f: Hello world
@dg

This comment has been minimized.

Copy link
Member

commented Mar 26, 2015

Is this valid?

d: someKey:
    e: Some next message

@dg dg closed this in 5d010dd Mar 26, 2015

@legendik

This comment has been minimized.

Copy link
Author

commented Mar 26, 2015

It was typo :-)
Thanks @dg! One more think, it still generates two unneeded newlines instead of one. For example:

a:
    b: Some text
    c: Some other text
    d:
        e: Some next message
#newLine
#newLine
f: Hello world

Is this valid, or can be fixed as well?

dg added a commit that referenced this issue Mar 26, 2015

@dg

This comment has been minimized.

Copy link
Member

commented Mar 26, 2015

Fixed

@legendik

This comment has been minimized.

Copy link
Author

commented Mar 26, 2015

Not properly :)

restaurant:
     notes:
          key1: Some message1
          key2: Some Message2
          key3: Some message3
disagreementState:
     key4: Some message4

Generates still two newlines:

restaurant:
     notes:
          key1: Some message1
          key2: Some Message2
          key3: Some message3
#first newline
#second newline
disagreementState:
     key4: Some message4

dg added a commit that referenced this issue Mar 26, 2015

@dg

This comment has been minimized.

Copy link
Member

commented Mar 26, 2015

uff, typo

@legendik

This comment has been minimized.

Copy link
Author

commented Mar 26, 2015

Awesome, thank you!

dg added a commit that referenced this issue Dec 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.