pub struct CodeBlock {
pub span: Option<Span>,
/* private fields */
}Fields§
§span: Option<Span>Implementations§
Source§impl CodeBlock
impl CodeBlock
Sourcepub fn lang(&self) -> Option<SharedString>
pub fn lang(&self) -> Option<SharedString>
Get the language of the code block.
Sourcepub fn meta(&self) -> Option<SharedString>
pub fn meta(&self) -> Option<SharedString>
The rest of the fence’s info string after the language, when any.
Sourcepub fn with_meta(self, meta: Option<SharedString>) -> Self
pub fn with_meta(self, meta: Option<SharedString>) -> Self
Sets the fence’s info string after the language. It is kept for round trips and is not rendered.
Sourcepub fn with_leaf_key(self, key: u64) -> Self
pub fn with_leaf_key(self, key: u64) -> Self
Marks this code block as a leaf of an external editor, like
Paragraph::with_leaf_key. Rekeying detaches runtime state from clones.
Sourcepub fn code(&self) -> SharedString
pub fn code(&self) -> SharedString
Get the code content of the code block.
Sourcepub fn from_code(
code: impl Into<SharedString>,
lang: Option<impl Into<SharedString>>,
) -> Self
pub fn from_code( code: impl Into<SharedString>, lang: Option<impl Into<SharedString>>, ) -> Self
Builds a code block that is not tied to a parsed document.
crate::TextView::code_block_highlighter hands a &CodeBlock to the
highlighter it is given, so anyone writing one needs a way to build a
block to exercise it against.
Sourcepub fn new(
code: SharedString,
lang: Option<SharedString>,
span: Option<impl Into<Span>>,
) -> Self
pub fn new( code: SharedString, lang: Option<SharedString>, span: Option<impl Into<Span>>, ) -> Self
A code block of code in lang.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CodeBlock
impl RefUnwindSafe for CodeBlock
impl Send for CodeBlock
impl Sync for CodeBlock
impl Unpin for CodeBlock
impl UnsafeUnpin for CodeBlock
impl UnwindSafe for CodeBlock
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more