Home Download Buy Blog Forum Support

(ST2|ST3) SerializedDataConverter (Beta)

(ST2|ST3) SerializedDataConverter (Beta)

Postby facelessuser on Fri Nov 08, 2013 7:36 am

ST2 and ST3: https://github.com/facelessuser/SerializedDataConverter

This will be the successor of PlistJsonConverter. SerializedDataConverter will convert plists, yaml and json to each other.

I have added a built-in yaml highlighter because sublime's yaml highlighter isn't even that usable. You can override the one I provided with Sublime's, or you can override with others such as AAAPackageDev's yaml. I personally am not using AAAPackageDev at this time its rules were a bit too sublime settings specific with keys and some other minor things. With that said, mine has flaws as well. I am working on yet another yaml highlighter to replace the current one which uses a different approach, to hopefully improve highlighting overall with yaml, and I also plan to look into AAAPackageDev's version as well to see if its flaws can be improved and even replace mine. Overall, I feel that PackageDev's and mine will allow you to edit languages and Sublime settings much better than Sublime's built-in one. If you want to use them to edit general yaml files outside of sublime settings, you can evaluate which one works better for you, or use something else entirely.

Example PHP conversion:
            beginCaptures:
'1':
name: storage.modifier.php
'2':
name: storage.type.function.php
'3':
name: storage.modifier.reference.php
'4':
name: support.function.magic.php
'5':
name: entity.name.function.php
'6':
name: punctuation.definition.parameters.begin.php
contentName: meta.function.arguments.php
end: (\))
endCaptures:
'1':
name: punctuation.definition.parameters.end.php
name: meta.function.php
patterns:
- include: '#function-arguments'
- include: '#invoke-call'
- begin: |-
(?xi)\s*(?=
[a-z_0-9$\\]+(::)
(?:
([a-z_][a-z_0-9]*)\s*\(
|
((\$+)[a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*)
|
([a-z_\x{7f}-\x{ff}][a-z0-9_\x{7f}-\x{ff}]*)
)?
)
end: |-
(?x)(::)
(?:
([A-Za-z_][A-Za-z_0-9]*)\s*\(
|
((\$+)[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
|
([a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)
)?
endCaptures:


I also added a little extra feature as well. When working with sublime settings, you can use !!regex (which is mapped to !!str for conversion), and it will highlight your data with regex highlighting. This way it isn't too sublime-specific, but you can still use it to edit tmLanguage files.
    ###################
# Lines
###################
# Scan the line for key value pairs
single-line:
begin: !!regex |-
(?x)^[\ ]*(?:
(?:([\-?])(?:[\ \r\n]+))?
(?:
(\w(?:.*?[^\ ])?|<<)(?:[\ \r\n]*(\:)(?:[\ \r\n]+|(?=$))) |
([']((?:(?:\\.)|(?:[^'\\]|'{2}))*?)['])(\:)(?:[\ \r\n]+|(?=$))|
(["]((?:(?:\\.)|(?:[^"\\]|\\"))*?)["])(\:)(?:[\ \r\n]+|(?=$))
)
)
beginCaptures:
'1': {name: keyword.operator.list.yaml-simple}
'2': {name: meta.tag.yaml-simple}
'3': {name: keyword.operator.key-separator.yaml-simple}
'4': {name: meta.tag.yaml-simple}
'5': {name: string.yaml-simple}
'6': {name: keyword.operator.key-separator.yaml-simple}
'7': {name: meta.tag.yaml-simple}
'8': {name: string.yaml-simple}
'9': {name: keyword.operator.key-separator.yaml-simple}
end: !!regex $
patterns:
- include: '#cast-values'
- include: '#values'

cast-values:
patterns:
- captures:
'1': {name: support.type.yaml-simple}
'2': {name: keyword.operator.multi-line.yaml-simple}
'3': {name: comment.yaml-simple}
match: !!regex (?:(!![\w//]+)[ ]+)?([|>][-+\d\r\n]*)[ \r\n]*(#.*)?$
- begin: !!regex (!!regex)[ ]+
beginCaptures:
'1': {name: support.type.yaml-simple}
end: !!regex (?=$)
patterns:
- include: '#sublime-regex'
- begin: !!regex (!![\w//]+)[ ]+
end: !!regex (?=$)
patterns:
- include: '#values'


Details are subject to change before release.

Anyways, if you wanted to play existing languages in yaml, this plugin will convert them over for you and provide a language file to edit it in. Then you can save it back to tmLanguage etc.
Last edited by facelessuser on Mon Nov 11, 2013 5:39 pm, edited 2 times in total.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3 (ST2?) SerializedDataConverter (Coming soon)

Postby icylace on Fri Nov 08, 2013 3:42 pm

Yes! Looking forward to using this!
icylace
 
Posts: 47
Joined: Mon Jan 14, 2013 7:24 am

Re: ST3 (ST2?) SerializedDataConverter (ST3 Beta)

Postby facelessuser on Fri Nov 08, 2013 5:53 pm

@icylace Give it a try https://github.com/facelessuser/SerializedDataConverter :). Let me know how it works.

If you have old json languages, you can convert them to yaml as well. You can convert yaml, json, and plist between each other (at least for basic stuff, I am still not sure about all of the yaml features and if they all translate, but as far as sublime languages, themes, settings, they should all translate back and forth to any of the supported formats.

ST3 only right now.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: ST3 (ST2?) SerializedDataConverter (ST3 Beta)

Postby facelessuser on Fri Nov 08, 2013 6:43 pm

Small update. I broke inline associative arrays...whoops! It is fixed now.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby facelessuser on Mon Nov 11, 2013 5:44 pm

Now beta works for ST2 and ST3.

Includes fixes for better output, and fixes to the built-in tmLanguage. Remember, if you don't like the yaml tmLanguage I provided, just override it in the settings file. I realize that most yaml tmLanguages have issues, and mine is no exception, so use the one that is best for you. I am working on yet another one to replace the current one I include (hopefully), I realized I would need a different approach to handle different formats of yaml to make this work as a decent general yaml language file, but again, this can always be overridden if you prefer other great yaml tmLanguages such as AAAPackageDev (one I am still looking into as a possible permanent replacement).

Updated OP
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby FichteFoll on Wed Nov 20, 2013 8:12 am

Subscribing~ (you know there is no other way)

Edit: That reminds me: I actually worked on a syntax definition for generic YAML before the one I made for AAAPackageDev but eventually considered it to be too much of a hassle because YAML is not really a regex language and then didn't look back at it again. I didn't make much progress though so it's not worth looking at.
FichteFoll
 
Posts: 377
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby facelessuser on Wed Nov 20, 2013 3:44 pm

Yeah, I know what you mean. I had to take a break. It is so labor intensive to come up with a general YAMl language. The language is a bit too flexible when it comes to trying to highlight it. And everything can take on so many varying forms.

This gets tiring.
# map type multi | keyword
? !!str |- # comment 1
keyword

# map type | multi | keyword
? !!str # comment 1
|- # comment 2
keyword

# map | type | keyword
? # comment 1
!!str # comment 2
key:#w# or:d #comment 2

? !!str
33 #yes
:

# map type keyword
? !!str keyword # comment 1

# map | type | keyword
? # comment 1
!!str # comment 2
"keyword" # comment 3

# map type keyword
? !!str 'keyword'

...

# map | type | keyword
- # comment 1
!!str # comment 2
keyword # comment 3

# map type keyword
- !!str keyword # comment 1

# map | type | keyword
- # comment 1
!!str # comment 2
'value' # comment 3

# map | type | keyword
- # comment 1
!!str # comment 2
yes # comment 3

...

- "name": #wh# at # dd

#
"name": !!regex (\t)[#hello]
"name": !!regex (\t)[ #hello]
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby facelessuser on Tue Jan 21, 2014 5:30 pm

SerializedDataConverter has now replaced JsonPlistConverter in Package Control (though it does not right now include the discussed YAML tmLanguage file which is a separate side project that I will make available).
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby facelessuser on Wed Jan 22, 2014 6:35 am

Update so translation of PLIST date and data tags translate correctly between JSON, PLIST, and YAML.

See https://github.com/facelessuser/Seriali ... r/issues/3 for more info.
facelessuser
 
Posts: 1542
Joined: Tue Apr 05, 2011 7:38 pm

Re: (ST2|ST3) SerializedDataConverter (Beta)

Postby aziz on Fri Jan 24, 2014 3:30 pm

Can't wait to have the better YAML.tmLanguage! mine looks horrible now when I convert from a complex plist
PlainTasks: my opinionated todo plugin
tmThemeEditor color-scheme editor for SumblimeText and Textmate (code on github)
aziz
 
Posts: 38
Joined: Thu Jan 12, 2012 6:29 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests