fabiospampinato / cson2json

A super-lightweight library for converting CSON objects to JSON objects.
MIT License
5 stars 1 forks source link

Implement indentation rules #1

Open craftzdog opened 4 years ago

craftzdog commented 4 years ago

Hi, thanks for making this! No coffeescript dependency is what I was searching for. But it doesn't work as expected. For example:

'global':
  'cmd-shift-y': 'application:toggle-main-window'
'body':
  'cmd-shift-s': 'core:sync-db'
'.CodeMirror textarea':
  'alt-shift-F': 'native!'

Yields actually:

{
  "global": {
    "cmd-shift-y": "application:toggle-main-window",
    "body": {
      "cmd-shift-s": "core:sync-db",
      ".CodeMirror textarea": {
        "alt-shift-F": "native!"
      }
    }
  }
}

Expected:

{
  "global": {
    "cmd-shift-y": "application:toggle-main-window"
  },
  "body": {
    "cmd-shift-s": "core:sync-db",
  },
  ".CodeMirror textarea": {
    "alt-shift-F": "native!"
  }
}

Could you look into it? Thanks in advance!

fabiospampinato commented 4 years ago

Indentation rules are kind of unimplemented yet: https://github.com/fabiospampinato/cson2json/blob/6cfbea16b7dc0bed9eeac4ce9caf7218d384dccd/src/parser/cson.pegjs#L2

They seemed pretty tricky to implement and I actually didn't need this, so I didn't implement them.

PR welcome though.

fabiospampinato commented 3 years ago

This should be rewritten with reghex, which should be pretty fun to do and would make the library smaller and faster.

craftzdog commented 3 years ago

Cool😍