pub struct HighlightedToken {
pub text: String,
pub color: HighlightColor,
pub bold: bool,
pub italic: bool,
}Expand description
A syntax-highlighted code token with styling information.
This struct represents a single token of code extracted by the syntax highlighter, including the token text, its color, and optional bold and italic styling.
§Fields
text- The content of the token (e.g., a keyword, identifier, or operator)color- The RGB color to apply to this token for renderingbold- Whether the token should be rendered in bolditalic- Whether the token should be rendered in italics
§Examples
Create a token for a keyword with bold styling:
use markdown2pdf::highlighting::{HighlightColor, HighlightedToken};
let token = HighlightedToken {
text: "fn".to_string(),
color: HighlightColor::from_rgb(167, 29, 93), // Magenta
bold: true,
italic: false,
};
assert_eq!(token.text, "fn");
assert_eq!(token.bold, true);
assert_eq!(token.italic, false);Fields§
§text: String§color: HighlightColor§bold: bool§italic: boolTrait Implementations§
Source§impl Clone for HighlightedToken
impl Clone for HighlightedToken
Source§fn clone(&self) -> HighlightedToken
fn clone(&self) -> HighlightedToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HighlightedToken
impl RefUnwindSafe for HighlightedToken
impl Send for HighlightedToken
impl Sync for HighlightedToken
impl Unpin for HighlightedToken
impl UnwindSafe for HighlightedToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.