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

yaml_emit Incorrectly Indents List Items Same as Parent #91

Open
mpql opened this issue Nov 5, 2024 · 2 comments
Open

yaml_emit Incorrectly Indents List Items Same as Parent #91

mpql opened this issue Nov 5, 2024 · 2 comments

Comments

@mpql
Copy link

mpql commented Nov 5, 2024

Hey there! I appreciate the work y'all do, and wanted to report a probable bug behavior I found.

I am on PHP 8.3.13, using the 2.2.4 version of the yaml extension — each the latest stable version, as of this writing.

$ php -v
# PHP 8.3.13 (cli) (built: Nov  4 2024 23:34:58) (NTS)
# Copyright (c) The PHP Group
# Zend Engine v4.3.13, Copyright (c) Zend Technologies
$ php -r 'echo phpversion() . "\n";'
# 8.3.13
$ php -r 'echo phpversion("yaml") . "\n";'
# 2.2.4

Given a file input.yaml (with line 6 being a blank line present, but omitted by GitHub):

---
root:
  node:
    - list item
...

We can parse and emit said file with the following code:

php -r 'echo yaml_emit(yaml_parse_file("input.yaml"));' > output.yaml

rendering output.yaml (with line 6 again being a blank line):

---
root:
  node:
  - list item
...

Note the newly incorrect indentation of the list item on line 4. yamllint throws an error for the same line.

$ yamllint -v
# yamllint 1.35.1
$ yamllint output.yaml
# output.yaml
#   4:3       error    wrong indentation: expected 4 but found 2  (indentation)

I've got a workaround on my end, though it's specific to my rather esoteric use case — but I figured I'd do my due diligence and report the issue.

@bd808
Copy link
Collaborator

bd808 commented Nov 5, 2024

This is a stylistic difference rather than a bug. Your project has adopted a style rule that is valid but not necessary.

@mpql
Copy link
Author

mpql commented Nov 5, 2024

This is a stylistic difference rather than a bug. Your project has adopted a style rule that is valid but not necessary.

Neither the program ingesting my yaml nor yamllint are my projects. That said, how do I tell yaml_emit not to stylistically mangle my input?

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

2 participants