From f60d344621a47726da7b9fbe7163b2a3fbc3f9ff Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 15 Feb 2023 23:32:13 +0100 Subject: [PATCH] Fix tutorial previews --- docs/src/html.rs | 23 ++++++++++++++++------- docs/src/tutorial/3-advanced.md | 4 ++-- docs/src/tutorial/4-template.md | 7 +++++-- library/src/layout/page.rs | 6 +++--- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/docs/src/html.rs b/docs/src/html.rs index ac48952d8..7802ee105 100644 --- a/docs/src/html.rs +++ b/docs/src/html.rs @@ -276,15 +276,20 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html { let mut parts = lang.split(':'); let lang = parts.next().unwrap_or(lang); + let mut zoom: Option<[Abs; 4]> = None; + let mut single = false; if let Some(args) = parts.next() { - zoom = args - .split(',') - .take(4) - .map(|s| Abs::pt(s.parse().unwrap())) - .collect::>() - .try_into() - .ok(); + single = true; + if !args.contains("single") { + zoom = args + .split(',') + .take(4) + .map(|s| Abs::pt(s.parse().unwrap())) + .collect::>() + .try_into() + .ok(); + } } if !matches!(lang, "example" | "typ") { @@ -312,6 +317,10 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html { *frames[0].size_mut() = Size::new(w, h); } + if single { + frames.truncate(1); + } + resolver.example(highlighted, &frames) } diff --git a/docs/src/tutorial/3-advanced.md b/docs/src/tutorial/3-advanced.md index ab65008cc..49eb8e310 100644 --- a/docs/src/tutorial/3-advanced.md +++ b/docs/src/tutorial/3-advanced.md @@ -202,7 +202,7 @@ Another tweak could be to save the paper title in a variable, so that we do not have to type it twice, for header and title. We can do that with the `{let}` keyword: -```example +```example:single #let title = [ A fluid dynamic model for glacier flow @@ -274,7 +274,7 @@ the document as a parameter. We have called the parameter `rest` here, but you are free to choose any name. The function can then do anything with this content. In our case, it passes it on to the `columns` function. -```example +```example:single >>> #let title = [ >>> A fluid dynamic model >>> for glacier flow diff --git a/docs/src/tutorial/4-template.md b/docs/src/tutorial/4-template.md index 6b176d321..7ecec0d13 100644 --- a/docs/src/tutorial/4-template.md +++ b/docs/src/tutorial/4-template.md @@ -125,7 +125,10 @@ previous chapter. columns(2, doc) } -#show: doc => conf([Paper title], doc) +#show: doc => conf( + [Paper title], + doc, +) = Introduction #lorem(90) @@ -256,7 +259,7 @@ adding an import before the show rule. Name the function that you want to import from another file between the `{import}` and `{from}` keywords and specify the path of the file after the `{from}` keyword. -```example +```example:single >>> #let conf( >>> title: none, >>> authors: (), diff --git a/library/src/layout/page.rs b/library/src/layout/page.rs index ac0e27cb0..d6862276f 100644 --- a/library/src/layout/page.rs +++ b/library/src/layout/page.rs @@ -119,7 +119,7 @@ impl PageNode { /// How many columns the page has. /// - /// ```example + /// ```example:single /// #set page(columns: 2, height: 4.8cm) /// Climate change is one of the most /// pressing issues of our time, with @@ -341,9 +341,9 @@ impl Debug for PageNode { } /// # Page Break -/// A page break. +/// A manual page break. /// -/// A manually forced page break. It must not be used inside any containers. +/// Must not be used inside any containers. /// /// ## Example /// ```example