-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(highlighting): add syntax highlighting support with syntect crate (
#313)
- Loading branch information
1 parent
1df3b1a
commit e65d0a7
Showing
11 changed files
with
617 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use owo_colors::Style; | ||
|
||
use crate::SpanContents; | ||
|
||
use super::{Highlighter, HighlighterState}; | ||
|
||
/// The default syntax highlighter. It applies `Style::default()` to input text. | ||
/// This is used by default when no syntax highlighting features are enabled. | ||
#[derive(Debug, Clone)] | ||
pub struct BlankHighlighter; | ||
|
||
impl Highlighter for BlankHighlighter { | ||
fn start_highlighter_state<'h>( | ||
&'h self, | ||
_source: &dyn SpanContents<'_>, | ||
) -> Box<dyn super::HighlighterState + 'h> { | ||
Box::new(BlankHighlighterState) | ||
} | ||
} | ||
|
||
impl Default for BlankHighlighter { | ||
fn default() -> Self { | ||
BlankHighlighter | ||
} | ||
} | ||
|
||
/// The default highlighter state. It applies `Style::default()` to input text. | ||
/// This is used by default when no syntax highlighting features are enabled. | ||
#[derive(Debug, Clone)] | ||
pub struct BlankHighlighterState; | ||
|
||
impl HighlighterState for BlankHighlighterState { | ||
fn highlight_line<'s>(&mut self, line: &'s str) -> Vec<owo_colors::Styled<&'s str>> { | ||
vec![Style::default().style(line)] | ||
} | ||
} |
Oops, something went wrong.