You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once #147 is merged, it becomes possible to control the indentation of the output. The current defaults for that match the way yaml has previously worked, such that 2 spaces are used for indents, and block sequences are indented.
It should be possible to automatically detect the indentation settings when parsing a source file, but I've not been able to figure out a foolproof way of doing it. So, rather than blocking on this, I'm documenting the issue and moving on:
This should be a part of the CST -> Document parsing, but it'll need to use data from the CST nodes before they're discarded.
CST nodes include node.context.indent, as a number indicating the indentation level from which their parsing started. There may still be white-space characters after that, before the node contents actually start.
Other relevant values are node.context.atLineStart to help filter out nodes from e.g. key: value single-line pairs, node.context.src for the normalised source, and node.range.start for the starting character index of the node.
Indentations happen when maps & sequences start, or when scalars span multiple lines; not all nodes' indentations need to be taken into account.
Flow collections indent differently from block collections.
Comment indentation levels should probably be ignored.
It's not necessarily easy to determine the indent level of the previous line.
Block sequence item indents are the really tricky thing.
This is an interesting problem, and if you feel like taking a stab at this, you're more than welcome. I may or may not return to this at some point.
This discussion was converted from issue #151 on December 11, 2020 12:25.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Once #147 is merged, it becomes possible to control the indentation of the output. The current defaults for that match the way
yaml
has previously worked, such that 2 spaces are used for indents, and block sequences are indented.It should be possible to automatically detect the indentation settings when parsing a source file, but I've not been able to figure out a foolproof way of doing it. So, rather than blocking on this, I'm documenting the issue and moving on:
node.context.indent
, as a number indicating the indentation level from which their parsing started. There may still be white-space characters after that, before the node contents actually start.node.context.atLineStart
to help filter out nodes from e.g.key: value
single-line pairs,node.context.src
for the normalised source, andnode.range.start
for the starting character index of the node.This is an interesting problem, and if you feel like taking a stab at this, you're more than welcome. I may or may not return to this at some point.
Beta Was this translation helpful? Give feedback.
All reactions