feat: add smart left indent RFC8792 folding#282
Conversation
cabo
left a comment
There was a problem hiding this comment.
Nice!
Sorry for nitpicking on the code.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
No worries, I welcome the direction. |
| rest = li[col..-1] | ||
| indent = left || columns - rest.size | ||
| if !left && li[-1] == "\\" | ||
| indent = left_indent || columns - rest.size |
There was a problem hiding this comment.
Hmm, makes me wonder whether there should be a smart_right (right-aligned, but not using more of the line to the left than smart indentation).
There was a problem hiding this comment.
possible in a follow up, and possibly after there's a test suite, this is getting to a point where changes could use a set of vectors to test with.
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
|
@cabo is there anything left to do here before merging and getting a release? |
|
Apologies for going on vacation before completing this. I think I had two questions in mind: 1 Is "smart" a good term for indentation based positioning? 2 Did we cover all combinations (here: right aligned with a left boundary based on indentation). |
Happy to change the name if one comes to mind.
It covers the use case I have for it. But I cannot foresee use cases or combinations others might have. |
Adds a smart indentation variant for automated RFC 8792 folding.
The new
smartNfold option can be used in the same position asleftN(they are mutually exclusive), for example:{::include-fold69hardsmart2dry generated.json}Unlike
leftN, which uses a fixed continuation indentation,smartNcomputes the continuation indentation from the line being folded:This is useful for nested structured data such as JSON, where folded continuation lines should stay visually aligned with the surrounding nesting level.
Since you moved the docs to the wiki I'll leave those to you to update if this gets accepted.
Example input:
{ "outer": { "array": [ { "description": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "nested": { "token": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" } } ] } }With
fold69hardsmart2dry: