yedit icon indicating copy to clipboard operation
yedit copied to clipboard

Auto-Format: Wrap string scalars to line width

Open tedepstein opened this issue 9 years ago • 1 comments

YEdit has a line width setting in auto-format, but it does not seem to be using this to break strings across lines.

At a minimum, I would like this to break strings that use the > folded string indicator:

   /estimates/price:
      get:
         summary: Price Estimates
         description: >
            The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.<br><br>The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.

This should become:

   /estimates/price:
      get:
         summary: Price Estimates
         description: >
            The Price Estimates endpoint returns an estimated price range for 
            each product offered at a given location. The price estimate is 
            provided as a formatted string with the full price range and the 
            localized currency symbol.<br><br>The response also includes low 
            and high estimates, and the
            [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code 
            for situations requiring currency conversion. When surge is active
             for a particular product, its surge_multiplier will be greater 
             than 1, but the price estimate already factors in this multiplier.

It would also be helpful to have the option to convert inline strings to block-style wrapped strings, where the inline string exceeds the line length. So the example below would be auto-formatted the same as in the example above:

   /estimates/price:
      get:
         summary: Price Estimates
         description: The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.<br><br>The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier.

NOTE: My knowledge of YAML is somewhat incomplete, so it's possible that I'm misunderstanding some of the rules. If someone thinks this looks incomplete or off-target, please chime in.

tedepstein avatar Feb 14 '16 21:02 tedepstein

The auto-formatting implementation in YEdit is quite broken actually. It is built upon the pretty-print serialisation feature in SnakeYAML and not really suited for good source formatting since it among other things strips away all comments.

The best way to fix this issue would be for someone to make a independent formatter for YAML but as far as I know no such project exists.

oyse avatar Mar 18 '16 18:03 oyse