//! Monospaced text and code. use once_cell::sync::Lazy; use syntect::easy::HighlightLines; use syntect::highlighting::{FontStyle, Highlighter, Style, Theme, ThemeSet}; use syntect::parsing::SyntaxSet; use super::prelude::*; use crate::library::TextNode; use crate::source::SourceId; use crate::syntax::{self, RedNode}; /// The lazily-loaded theme used for syntax highlighting. static THEME: Lazy = Lazy::new(|| ThemeSet::load_defaults().themes.remove("InspiredGitHub").unwrap()); /// The lazily-loaded syntect syntax definitions. static SYNTAXES: Lazy = Lazy::new(|| SyntaxSet::load_defaults_newlines()); /// Monospaced text with optional syntax highlighting. #[derive(Debug, Hash)] pub struct RawNode { /// The raw text. pub text: EcoString, /// Whether the node is block-level. pub block: bool, } #[class] impl RawNode { /// The language to syntax-highlight in. pub const LANG: Option = None; fn construct(_: &mut Vm, args: &mut Args) -> TypResult