REFACTOR: Remove cases other than [], [x], and [X] (PR #23)


The reason for having both these regex’s instead of one, is to retain the optional whitespace before the checklists.

Are you using this?

Whitespace :wink:

    lines = @post.raw.split("\n")

Could update_syntax! be just this instead?

  def update_syntax!
    @post.raw = @post.raw.gsub(/^({,3})\[(_|-|\*|\\\*)\]/) { "#{$1}[x]" }!

3, 5, and 6 ("[*]", "[\*]", and "[*\]") test exactly the same thing as single escape characters (\) in that string are removed during parsing of this .rb file and don’t make it to the ChecklistSyntaxMigrator.

As pointed out by Sam, checkboxes in multiline code blocks with back-ticks also should be skipped.

Are checkboxes after text not converted to avoid false-positive migrations? Checkboxes in lists are a common case:

* [x] task1

- [ ] something

1. [ ] todo

Yes, they are not converted to avoid false positives. This was Jeff’s request

@CvX I just added a commit so that inside code blocks and quotes, checkboxes wont be converted.