pub struct SqlHighlighter { /* private fields */ }Expand description
SQL highlighting as a CodeHighlighter, for Syntax, Markdown code
fences and the console’s code highlighting.
Implementations§
Source§impl SqlHighlighter
impl SqlHighlighter
Sourcepub fn with_fallback(fallback: Arc<dyn CodeHighlighter>) -> Self
pub fn with_fallback(fallback: Arc<dyn CodeHighlighter>) -> Self
SQL here, every other language through fallback (syntect, lumis or
another engine).
use std::sync::Arc;
use rich::protocol::CodeHighlighter;
use rich_ext::sql::SqlHighlighter;
let both = SqlHighlighter::with_fallback(Arc::new(SqlHighlighter::new()));
assert!(both.languages().contains(&"duckdb".to_string()));One shared instance with no fallback.
Trait Implementations§
Source§impl Clone for SqlHighlighter
impl Clone for SqlHighlighter
Source§impl CodeHighlighter for SqlHighlighter
impl CodeHighlighter for SqlHighlighter
Source§fn highlight(
&self,
code: &str,
language: Option<&str>,
theme: &str,
) -> Result<HighlightedCode, HighlightError>
fn highlight( &self, code: &str, language: Option<&str>, theme: &str, ) -> Result<HighlightedCode, HighlightError>
Highlight
code. language is a name or file extension ("rust",
"rs"); None means plain text. theme is one of themes.Source§fn default_theme(&self) -> &str
fn default_theme(&self) -> &str
The theme used when none is chosen.
Source§fn languages(&self) -> Vec<String>
fn languages(&self) -> Vec<String>
Language names this highlighter knows, for help text and completion.
Source§fn language_for_path(&self, path: &Path) -> Option<String>
fn language_for_path(&self, path: &Path) -> Option<String>
The language for a file path, if the highlighter recognises it.
Source§fn token_style(&self, theme: &str, token: &str) -> Option<Style>
fn token_style(&self, theme: &str, token: &str) -> Option<Style>
theme’s style for a Pygments token type — "Text" or "Comment" —
as upstream’s SyntaxTheme.get_style_for_token. Syntax colours its
line numbers and indent guides with it; None (the default) means the
theme sets nothing for the token.Source§impl Debug for SqlHighlighter
impl Debug for SqlHighlighter
Auto Trait Implementations§
impl !RefUnwindSafe for SqlHighlighter
impl !UnwindSafe for SqlHighlighter
impl Freeze for SqlHighlighter
impl Send for SqlHighlighter
impl Sync for SqlHighlighter
impl Unpin for SqlHighlighter
impl UnsafeUnpin for SqlHighlighter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more