Fix tutorial previews

This commit is contained in:
Laurenz 2023-02-15 23:32:13 +01:00
parent 310c229c61
commit f60d344621
4 changed files with 26 additions and 14 deletions

View File

@ -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::<Vec<_>>()
.try_into()
.ok();
single = true;
if !args.contains("single") {
zoom = args
.split(',')
.take(4)
.map(|s| Abs::pt(s.parse().unwrap()))
.collect::<Vec<_>>()
.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)
}

View File

@ -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

View File

@ -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: (),

View File

@ -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