diff options
| author | Pg Biel <9021226+PgBiel@users.noreply.github.com> | 2023-05-11 11:32:46 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-11 16:32:46 +0200 |
| commit | b5ad2468adafca40448035c80fdabab4b5f75a0f (patch) | |
| tree | 2b0d1ea4d29df9c21fb714d539dca7a8703452b9 /library/src/text | |
| parent | d19a4124de60b043e36e76dfe20fca193deb6a41 (diff) | |
Improve alignment of text inside raw blocks (#1034)
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/raw.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index 4a9a925c..4cc26fa6 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -102,6 +102,27 @@ pub struct RawElem { /// ``` /// ```` pub lang: Option<EcoString>, + + /// The horizontal alignment that each line in a raw block should have. + /// This option is ignored if this is not a raw block (if specified + /// `block: false` or single backticks were used in markup mode). + /// + /// By default, this is set to `{start}`, meaning that raw text is + /// aligned towards the start of the text direction inside the block + /// by default, regardless of the current context's alignment (allowing + /// you to center the raw block itself without centering the text inside + /// it, for example). + /// + /// ````example + /// #set raw(align: center) + /// + /// ```typc + /// let f(x) = x + /// code = "centered" + /// ``` + /// ```` + #[default(HorizontalAlign(GenAlign::Start))] + pub align: HorizontalAlign, } impl RawElem { @@ -180,6 +201,8 @@ impl Show for RawElem { }; if self.block(styles) { + // Align the text before inserting it into the block. + realized = realized.aligned(Axes::with_x(Some(self.align(styles).into()))); realized = BlockElem::new().with_body(Some(realized)).pack(); } |
