Skip to content

Encoder generates unneeded indentation and new lines #20

@legendik

Description

@legendik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions