Skip to content

Commit

Permalink
Update CSS parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Apr 29, 2024
1 parent 688aaa8 commit 2e01656
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Since difftastic is now conservative with parse errors
(DFT_PARSE_ERROR_LIMIT is 0 by default), this seems like a better
tradeoff.

Updated CSS parser.

### Diffing

`--strip-cr` now defaults to `on`, so comparing a file with CRLF
Expand Down
2 changes: 1 addition & 1 deletion sample_files/compare.expected
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ sample_files/tab_before.txt sample_files/tab_after.txt
c7fcee21dd5ebd251e2cf4cd7d4446d2 -

sample_files/tailwind_before.css sample_files/tailwind_after.css
be0cba204957b62a30e99fd03f945de5 -
4fbb1d828afa99ad722944d97266e89e -

sample_files/text_before.txt sample_files/text_after.txt
5fa6a472ccdeda0142eda3edcaeaa189 -
Expand Down
11 changes: 8 additions & 3 deletions src/parse/tree_sitter_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,14 @@ pub(crate) fn from_language(language: guess::Language) -> TreeSitterConfig {
let language = unsafe { tree_sitter_css() };
TreeSitterConfig {
language,
atom_nodes: vec!["integer_value", "float_value", "color_value"]
.into_iter()
.collect(),
atom_nodes: vec![
"integer_value",
"float_value",
"color_value",
"string_value",
]
.into_iter()
.collect(),
delimiter_tokens: vec![("{", "}"), ("(", ")")],
highlight_query: ts::Query::new(
language,
Expand Down

0 comments on commit 2e01656

Please sign in to comment.