Skip to content

Consider removing last_non_blank #81

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

Closed
zbraniecki opened this issue Jan 24, 2019 · 3 comments
Closed

Consider removing last_non_blank #81

zbraniecki opened this issue Jan 24, 2019 · 3 comments

Comments

@zbraniecki
Copy link
Collaborator

Yeah, but why? :) What does last_non_blank keep track of?

Originally posted by @stasm in #76

@zbraniecki
Copy link
Collaborator Author

The reason I need the last_non_blank is primarily to separate \n as a text line separator in the pattern from pattern end delimiter.

The former gets included in the production, but the latter does not.

So, in a scenario like this:

key = This is
  a multiline

  value


key2 = Value 2

I will get the following elements for key's value:

[
    TextElement(  // "This is\n"
        6,
        14,
        0,
        InitialLineStart
    ),
    TextElement( // "  a multiline\n"
        14,
        28,
        2,
        LineStart
    ),
    TextElement( // "\n"
        28,
        29,
        0,
        LineStart
    ),
    TextElement( // "  value\n"
        29,
        37,
        2,
        LineStart
    ),
    TextElement( // "\n"
        37,
        38,
        0,
        LineStart
    ),
    TextElement( // "\n"
        38,
        39,
        0,
        LineStart
    )
]

I need to:

  • Remove the trailing two TextElement's from production
  • Remove the \n from the last remaining TextElement

both of those goals can be achieved with last_non_blank which keeps track of the element which is the last_non_blank allowing me to limit the iteration and separate out how I trim the \n from the end of the last non blank element.

@stasm - do you have alternative suggestion for this?

@zbraniecki
Copy link
Collaborator Author

@stasm - ping? I'd like to close it one way or the other.

I'm not sure if there's any better way to handle that.

@zbraniecki
Copy link
Collaborator Author

closing as per lack of activity.

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

No branches or pull requests

1 participant