Skip to content

Trim trailing whitespace in TextElements #247

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

Merged

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jul 10, 2018

No description provided.

@stasm stasm force-pushed the trim-trailing-whitespace branch from 5d4719e to 20cfdae Compare July 10, 2018 14:11
@stasm stasm requested a review from Pike July 10, 2018 14:20
Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a nit about the ..

But really, I'm not sure trimRight is right.
Can you add a test for nbsp or zwnj?

Also, if it is, use trimEnd, as that's what's standardized?

# < whitespace >
key1 = Value

key2 = Value {placeable}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you didn't mean to have the trailing . here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doch doch. I only meant to test that TextElements not in the last position are not affected by the trimming logic.

@stasm
Copy link
Contributor Author

stasm commented Jul 10, 2018

Can you add a test for nbsp or zwnj?

Ah, I see what you mean. Let me see.

Also, if it is, use trimEnd, as that's what's standardized?

It's only available in Firefox 61+ and Chrome 66+, and not in node. I don't want to get bitten by its being missing in a compat build or something.

@stasm stasm requested review from Pike and zbraniecki July 10, 2018 15:13
// non-empty line will decide what to do with it.
const firstLineContent = start !== eol
// Trim the trailing whitespace in case this is a single-line pattern.
// Multiline patterns are parsed anew by getComplexPattern.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to one day be able to pass first line to complex string and go from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's doable, but keep in mind that we'd need to parse firstLineContent in getComplexPattern anyways in case it contains placeables or escape sequences. The current approach of rewinding the index to the beginning of the first line works pretty well IMO.

@stasm stasm merged commit d159b36 into projectfluent:feature/syntax-0.6 Jul 11, 2018
@stasm stasm deleted the trim-trailing-whitespace branch July 11, 2018 10:47
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.

3 participants