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

Normalize indent #37

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open

Normalize indent #37

wants to merge 1 commit into from

Conversation

zdenko
Copy link
Contributor

@zdenko zdenko commented Sep 18, 2021

This PR fixes a bug with firstIndent in the reduceLines function.
The Indent token consists of two space character groups or one tab.
In my previous, quick solution, I forgot to test cases with an odd number of spaces.
In such cases, the parser can't detect the TagName token because of the "orphaned" space character in front.
For example, in this case (symbol represents a space) :

var templateFoo = `div
⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔span @name

there are 21 spaces. The parser will detect ten indents but will not detect LineBody token because of preceding space character (e.g., ⊔span).

To solve this, I added a rule for the TagName token, which now allows a single space character preceding an Indetifier token.

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.

1 participant