Skip to content

Add indentation.#3

Open
bemehiser wants to merge 1 commit into
mame:mainfrom
bemehiser:main
Open

Add indentation.#3
bemehiser wants to merge 1 commit into
mame:mainfrom
bemehiser:main

Conversation

@bemehiser

Copy link
Copy Markdown

Add the ability to specify indentation.

  • intent - the number of spaces of indentation per level

@bemehiser

Copy link
Copy Markdown
Author

@mame, any change you can review and merge this? I'd love to have the new changes for my projects. Thanks!

@mame

mame commented Feb 9, 2024

Copy link
Copy Markdown
Owner

Thank you, but I'm a little cautious about this feature though. This is because I think of some variants on the possible indentation style.

  • Nested indent (proposed?)
[foo]
  key = value
  [foo.bar]
    key = value
    [foo.bar.baz]
      key = value
  • Nested indent, but not indent key = value
[foo]
key = value
  [foo.bar]
  key = value
    [foo.bar.baz]
    key = value
  • No nested indent, but indents only key = value
[foo]
  key = value
[foo.bar]
  key = value
[foo.bar.baz]
  key = value
  • Indent by spaces, or indent by hard tabs
  • What output should be produced when combined with use_dot option

I should research what other major TOML encoder implementations offer in terms of formatting options.

@bemehiser

Copy link
Copy Markdown
Author
  • I personally use the third option with no nested indent.

  • I strongly recommend using spaces and not tabs. All the common IDEs use spaces instead of tabs, because tabs are inconsistent. The way I made this you can specify the number of spaces you want sections to be indented by. Common options are 2 or 4 spaces.

If you would prefer to use the nested indent schema, I could see about making that work and updating this merge request. I don't have a huge preference about indentation. Either option 1 or 3 would be fine. Any indentation will be better than no indentation.

@bemehiser

Copy link
Copy Markdown
Author

Hey @mame, just checking in to see if you had any further input on this. I really would like to have indentation added soon so I don't have to fork and push a new gem just to add the feature to my project.

Is there a specific indentation format I can implement which you would merge?

@paddor

paddor commented Oct 8, 2024

Copy link
Copy Markdown

Any updates here?

@bemehiser

bemehiser commented Oct 8, 2024

Copy link
Copy Markdown
Author

@paddor , there was no movement so I published my own version of the gem which includes the indentation changes.
https://rubygems.org/gems/perfect_toml_improved

I plan on deleting it if/when indentation support gets added to perfect_toml, so don't depend on it unless you are okay with it vanishing in the future.

@paddor

paddor commented Oct 8, 2024

Copy link
Copy Markdown

@bemehiser Thanks for the info.

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

Successfully merging this pull request may close these issues.

3 participants