fix: patch over ts tsx jsx issue
3c7b28be
2 file(s) · +10 −2
| 20 | 20 | } |
|
| 21 | 21 | ||
| 22 | 22 | pub fn highlight(&self, name: &str, content: &str) -> String { |
|
| 23 | - | let ext = name.rsplit('.').next().unwrap_or(""); |
|
| 23 | + | let raw_ext = name.rsplit('.').next().unwrap_or(""); |
|
| 24 | + | let ext = match raw_ext { |
|
| 25 | + | "ts" | "tsx" | "jsx" => "js", |
|
| 26 | + | other => other, |
|
| 27 | + | }; |
|
| 24 | 28 | let syntax = self |
|
| 25 | 29 | .syntax_set |
|
| 26 | 30 | .find_syntax_by_extension(ext) |
| 249 | 249 | } |
|
| 250 | 250 | ||
| 251 | 251 | fn highlight_content(&self, name: &str, content: &str) -> Text<'static> { |
|
| 252 | - | let ext = name.rsplit('.').next().unwrap_or(""); |
|
| 252 | + | let raw_ext = name.rsplit('.').next().unwrap_or(""); |
|
| 253 | + | let ext = match raw_ext { |
|
| 254 | + | "ts" | "tsx" | "jsx" => "js", |
|
| 255 | + | other => other, |
|
| 256 | + | }; |
|
| 253 | 257 | let syntax = self |
|
| 254 | 258 | .syntax_set |
|
| 255 | 259 | .find_syntax_by_extension(ext) |