Skip to content

Commit

Permalink
allow whitespace before closing > (#2021)
Browse files Browse the repository at this point in the history
* allow whitespace before closing `>`

fixes #2020

* another small enhancement
  • Loading branch information
anmonteiro authored and chenglou committed Jun 22, 2018
1 parent 7089a72 commit bc2240b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions formatTest/unit_tests/expected_output/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,10 @@ let x = foo /></ bar;
<div onClick=this##handleClick>
<> foo bar </>
</div>;

/* https://github.com/facebook/reason/issues/2020 */
<div />;

<div> foo </div>;

<div />;
7 changes: 7 additions & 0 deletions formatTest/unit_tests/input/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,10 @@ let x = foo /></ bar;
<div onClick=this##handleClick>
<> foo(bar) </>
</div>;

/* https://github.com/facebook/reason/issues/2020 */
<div></div >;

<div>foo</ div>;

<div> </ div >;
4 changes: 2 additions & 2 deletions src/reason-parser/reason_lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ rule token = parse
set_lexeme_length lexbuf 1;
LBRACE
}
| "</" uppercase_or_lowercase (identchar | '.') * ">" {
| "</" blank* uppercase_or_lowercase (identchar | '.') * blank* ">" {
let buf = Lexing.lexeme lexbuf in
LESSSLASHIDENTGREATER (String.sub buf 2 (String.length buf - 2 - 1))
LESSSLASHIDENTGREATER (String.trim (String.sub buf 2 (String.length buf - 2 - 1)))
}
| "]" { RBRACKET }
| "{" { LBRACE }
Expand Down

0 comments on commit bc2240b

Please sign in to comment.