diff options
Diffstat (limited to 'library/src/text/raw.rs')
| -rw-r--r-- | library/src/text/raw.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 3c9f86e5..2324eb21 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -6,6 +6,7 @@ use super::{ FontFamily, FontList, Hyphenate, LinebreakElem, SmartQuoteElem, TextElem, TextSize, }; use crate::layout::BlockElem; +use crate::meta::{Figurable, LocalName}; use crate::prelude::*; /// Raw text with optional syntax highlighting. @@ -35,7 +36,7 @@ use crate::prelude::*; /// /// Display: Raw Text / Code /// Category: text -#[element(Synthesize, Show, Finalize)] +#[element(Synthesize, Show, Finalize, LocalName, Figurable)] pub struct RawElem { /// The raw text. /// @@ -121,8 +122,10 @@ impl RawElem { } impl Synthesize for RawElem { - fn synthesize(&mut self, styles: StyleChain) { + fn synthesize(&mut self, _vt: &mut Vt, styles: StyleChain) -> SourceResult<()> { self.push_lang(self.lang(styles)); + + Ok(()) } } @@ -197,6 +200,24 @@ impl Finalize for RawElem { } } +impl LocalName for RawElem { + fn local_name(&self, lang: Lang) -> &'static str { + match lang { + Lang::CHINESE => "代码", + Lang::ITALIAN => "Codice", + Lang::RUSSIAN => "код", + Lang::FRENCH => "Liste", + Lang::ENGLISH | Lang::GERMAN | _ => "Listing", + } + } +} + +impl Figurable for RawElem { + fn priority(&self, _styles: StyleChain) -> isize { + 500 + } +} + /// Highlight a syntax node in a theme by calling `f` with ranges and their /// styles. fn highlight_themed<F>( |
