summaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/src')
-rw-r--r--library/src/text/raw.rs23
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();
}