Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option setOrigRanges for parsing docs #227

Closed
wants to merge 1 commit into from

Conversation

1nVitr0
Copy link

@1nVitr0 1nVitr0 commented Feb 5, 2021

This pull request adds the following parameter to the document parser:

setOrigRanges?: boolean

It uses the same name as the corresponding function setOrigRanges, which sets original ranges on cstNodes for \r\n style line endings. Default is false and it obviously only has an effect when keepCstNodes is set to true, although it does get executed either way, just that the CST nodes get discarded when keepCstNodes is set to false.

I realize adding more options should always be considered carefully, but being able to set the original ranges when parsing a document was pretty useful for me.

@1nVitr0 1nVitr0 changed the title feat: add option setOrigRanges for parsing docs Add option setOrigRanges for parsing docs Feb 5, 2021
@eemeli
Copy link
Owner

eemeli commented Feb 5, 2021

I'm going to hold off on really considering this until #203 gets merged, because that might remove the need for this: the new parser doesn't normalise the line endings. OTOH, atm it's only tracking the start indices of nodes, and I haven't figured out exactly yet if or how to provide end indices as well.

@eemeli
Copy link
Owner

eemeli commented Feb 21, 2021

Closing, as CRLF newlines are no longer converted to LF at any parsing stage, and range positions are always valid for the original string.

@eemeli eemeli closed this Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants