Skip to content

YAML flow syntax would benefit from some examples #101

@tobinjt

Description

@tobinjt

G'day.

Thanks for writing keep-sorted, I love it :)

I'm trying to sort a list of "key" = "value" pairs by value, then key. I want to use by_regex, but I cannot figure out the escaping. Here's my input (pre-sorting):

    ["UAA"] = "STOP",
    ["UAC"] = "Tyrosine",
    ["UAG"] = "STOP",
    ["UAU"] = "Tyrosine",
    ["UCA"] = "Serine",
    ["UCC"] = "Serine",
    ["UCG"] = "Serine",
    ["UCU"] = "Serine",
    ["UGA"] = "STOP",
    ["UGC"] = "Cysteine",
    ["UGG"] = "Tryptophan",
    ["UGU"] = "Cysteine",
    ["UUA"] = "Leucine",
    ["UUC"] = "Phenylalanine",
    ["UUG"] = "Leucine",
    ["UUU"] = "Phenylalanine"

I'm trying to include the double quotes to anchor the regex, and include a comma in {4,} to match 4 or more. Here are some attempts and error messages:

by_regex=["\\w{4,}," "..."]
WRN while parsing option "by_regex": yaml: did not find expected ',' or ']'

by_regex=["\w{4,}, "..."]
WRN while parsing option "by_regex": content appears to be an unterminated YAML list: "[\"\\w{4,}, \"...\"]"

by_regex=["\w{4}, "..."]
WRN while parsing option "by_regex": content appears to be an unterminated YAML list: "[\"\\w{4}, \"...\"]"

I've read https://yaml.org/spec/1.2.2/#flow-sequences and I can't see how to apply it here :( The examples for by_regex are really helpful, perhaps someone who understands the flow sequences could add some examples please? Commas and double quotes in the examples would be very helpful.

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions