File tree 3 files changed +27
-2
lines changed
3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
1
use harper_core:: parsers:: { self , Parser , PlainEnglish } ;
2
- use harper_core:: Token ;
2
+ use harper_core:: { Token , TokenKind } ;
3
3
use harper_tree_sitter:: TreeSitterMasker ;
4
4
use tree_sitter:: Node ;
5
5
6
6
pub struct HtmlParser {
7
+ /// Used to grab the text nodes.
7
8
inner : parsers:: Mask < TreeSitterMasker , PlainEnglish > ,
8
9
}
9
10
@@ -26,6 +27,14 @@ impl Default for HtmlParser {
26
27
27
28
impl Parser for HtmlParser {
28
29
fn parse ( & self , source : & [ char ] ) -> Vec < Token > {
29
- self . inner . parse ( source)
30
+ let mut tokens = self . inner . parse ( source) ;
31
+
32
+ for token in & mut tokens {
33
+ if let TokenKind :: Space ( v) = & mut token. kind {
34
+ * v = ( * v) . clamp ( 0 , 1 ) ;
35
+ }
36
+ }
37
+
38
+ tokens
30
39
}
31
40
}
Original file line number Diff line number Diff line change @@ -38,3 +38,4 @@ macro_rules! create_test {
38
38
39
39
create_test ! ( run_on. html, 0 ) ;
40
40
create_test ! ( issue_156. html, 0 ) ;
41
+ create_test ! ( issue_541. html, 0 ) ;
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="utf-8 ">
6
+ </ head >
7
+
8
+ < body >
9
+ < p >
10
+ This block contains multiple lines of HTML. If Harper is throwing a "too many spaces" lint, it's
11
+ because < code > harper-html</ code > isn't properly parsing the indent.
12
+ </ p >
13
+ </ body >
14
+
15
+ </ html >
You can’t perform that action at this time.
0 commit comments