diff options
| author | Sébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com> | 2023-04-04 19:21:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-04 19:21:25 +0200 |
| commit | f347ed4314e32383dc09ff234180e8ea6fef7b8b (patch) | |
| tree | dba4296812a131e52da4eb0079fd0d240860d832 /library/src/text | |
| parent | 5b0297464efc131beb7be84fa7a02b9a8670b5dd (diff) | |
Improved figure numbering, labelling and referencing (#491)
Diffstat (limited to 'library/src/text')
| -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>( |
