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

inline comments, after the setting value #13

Open
gregnis opened this issue Aug 29, 2024 · 4 comments
Open

inline comments, after the setting value #13

gregnis opened this issue Aug 29, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@gregnis
Copy link

gregnis commented Aug 29, 2024

In the following example

[section name]
some_key = some_value # comment
another-key = another value ; comment

[another section]
# a comment
;some_key = some_value
an#other-key = another value

comments on lines 2 and 3 are not detected whereas all other are:

document [0, 0] - [8, 0]
  section [0, 0] - [3, 0]
    section_name [0, 0] - [1, 0]
      text [0, 1] - [0, 13]
    setting [1, 0] - [2, 0]
      setting_name [1, 0] - [1, 8]
      setting_value [1, 10] - [1, 31]
    setting [2, 0] - [3, 0]
      setting_name [2, 0] - [2, 11]
      setting_value [2, 13] - [2, 37]
  section [4, 0] - [5, 0]
    section_name [4, 0] - [5, 0]
      text [4, 1] - [4, 16]
  comment [5, 0] - [6, 0]
    text [5, 1] - [5, 11]
  comment [6, 0] - [7, 0]
    text [6, 1] - [6, 22]
  ERROR [7, 0] - [7, 2]
    setting_name [7, 0] - [7, 2]
  comment [7, 2] - [8, 0]
    text [7, 3] - [7, 28]

``

@justinmk
Copy link
Owner

justinmk commented Aug 29, 2024

Can't find a reference about this. https://stackoverflow.com/a/19550081/152142 indicates that there is no spec for this.

If this was supported, then "#" could not be used in setting values (unless it was escaped; is there a standard escape char?).

Also, this directly conflicts with #12 .

Need a clear spec one way or the other. Else we're just fumbling around and will do unexpected things depending on the INI "flavor". A spec for each "flavor" would be a starting point.

@justinmk justinmk added the enhancement New feature or request label Aug 29, 2024
@justinmk justinmk changed the title Comments are not recognized at line end (after the setting) comments end of line (EOL), after the setting value Aug 29, 2024
@justinmk justinmk changed the title comments end of line (EOL), after the setting value comments at end of line (EOL), after the setting value Aug 29, 2024
@gregnis
Copy link
Author

gregnis commented Aug 29, 2024

I was going off https://en.wikipedia.org/wiki/INI_file, the Comments section. I do agree with you about following GetPrivateProfileString as a spec, and if you do that, the current behavior is almost correct. I say "almost" since, if there is a comment symbol in the setting name, like in

an#other-key = another value

it is treated as a comment after and including the '#', which makes the behavior inconsistent.

@justinmk justinmk changed the title comments at end of line (EOL), after the setting value inline comments, after the setting value Aug 30, 2024
@justinmk
Copy link
Owner

https://en.wikipedia.org/wiki/INI_file#Comments

... Under the WinAPI's GetPrivateProfileString's dialect, comments must occur on lines by themselves.

This seems the most reasonable. Especially given that escape chars don't seem standard.

OTOH, gitconfig appears to support inline comments, except when quoted in a string?

@gregnis
Copy link
Author

gregnis commented Aug 30, 2024

OTOH, gitconfig appears to support inline comments, except when quoted in a string?

I think this is the most reasonable thing to do, if possible,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants