pomsky icon indicating copy to clipboard operation
pomsky copied to clipboard

Create an auto-formatter

Open Aloso opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

There is currently no way to automatically format a pomsky expression.

Describe the solution you'd like

A tool, part of pomsky-bin, that accepts several configuration options similar to prettier, parses a pomsky expression losslessly (preserving comments and whitespace), and returns a pomsky expression that is beautifully formatted, without changing its semantic meaning. Here are some things it can do:

  • Add/remove white space
  • Add/remove a leading pipe
  • Remove unnecessary parentheses
  • Convert double quotes to single quotes or vice versa
  • Simplify repetitons (e.g. {1,} -> +)
  • Wrap comments
  • Replace deprecated syntax

Things it can not (or should not) do:

  • Do anything that changes what the expression can match
  • Rename identifiers
  • Remove or reorder comments
  • Reorder alternatives or character set contents
  • Remove unreachable expressions

Aloso avatar Aug 02 '22 13:08 Aloso