pub struct Code {
pub common: Common,
pub source: String,
pub language: Option<String>,
pub line_numbers: Option<bool>,
pub start_line: Option<u32>,
pub highlight_lines: Vec<u32>,
pub wrap: Option<bool>,
}Expand description
Syntax-highlighted code (§4.5.2). TUI: syntect; app: the chat code-block renderer.
Fields§
§common: CommonCommon node props (key, style, block, fallback).
source: StringCode source.
language: Option<String>Language id (rust, mermaid, …).
line_numbers: Option<bool>Render line numbers.
start_line: Option<u32>First line number (default 1).
highlight_lines: Vec<u32>Highlighted (1-based) line numbers.
wrap: Option<bool>Wrap long lines (default false = horizontal scroll).
Implementations§
Source§impl Code
impl Code
Sourcepub fn line_numbers(self, line_numbers: bool) -> Self
pub fn line_numbers(self, line_numbers: bool) -> Self
Renders line numbers.
Sourcepub fn start_line(self, start_line: u32) -> Self
pub fn start_line(self, start_line: u32) -> Self
Sets the first line number.
Sourcepub fn highlight_lines(self, lines: impl IntoIterator<Item = u32>) -> Self
pub fn highlight_lines(self, lines: impl IntoIterator<Item = u32>) -> Self
Sets the highlighted (1-based) lines.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Code
impl<'de> Deserialize<'de> for Code
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Code
Source§impl WithCommon for Code
impl WithCommon for Code
Source§fn common_mut(&mut self) -> &mut Common
fn common_mut(&mut self) -> &mut Common
Mutable access to the node’s common props.
Source§fn block(self, block: impl Into<BlockProps>) -> Self
fn block(self, block: impl Into<BlockProps>) -> Self
Sets the surrounding block.
Auto Trait Implementations§
impl Freeze for Code
impl RefUnwindSafe for Code
impl Send for Code
impl Sync for Code
impl Unpin for Code
impl UnsafeUnpin for Code
impl UnwindSafe for Code
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