mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Fix tutorial previews
This commit is contained in:
parent
310c229c61
commit
f60d344621
@ -276,15 +276,20 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html {
|
|||||||
|
|
||||||
let mut parts = lang.split(':');
|
let mut parts = lang.split(':');
|
||||||
let lang = parts.next().unwrap_or(lang);
|
let lang = parts.next().unwrap_or(lang);
|
||||||
|
|
||||||
let mut zoom: Option<[Abs; 4]> = None;
|
let mut zoom: Option<[Abs; 4]> = None;
|
||||||
|
let mut single = false;
|
||||||
if let Some(args) = parts.next() {
|
if let Some(args) = parts.next() {
|
||||||
zoom = args
|
single = true;
|
||||||
.split(',')
|
if !args.contains("single") {
|
||||||
.take(4)
|
zoom = args
|
||||||
.map(|s| Abs::pt(s.parse().unwrap()))
|
.split(',')
|
||||||
.collect::<Vec<_>>()
|
.take(4)
|
||||||
.try_into()
|
.map(|s| Abs::pt(s.parse().unwrap()))
|
||||||
.ok();
|
.collect::<Vec<_>>()
|
||||||
|
.try_into()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !matches!(lang, "example" | "typ") {
|
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);
|
*frames[0].size_mut() = Size::new(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if single {
|
||||||
|
frames.truncate(1);
|
||||||
|
}
|
||||||
|
|
||||||
resolver.example(highlighted, &frames)
|
resolver.example(highlighted, &frames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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}`
|
have to type it twice, for header and title. We can do that with the `{let}`
|
||||||
keyword:
|
keyword:
|
||||||
|
|
||||||
```example
|
```example:single
|
||||||
#let title = [
|
#let title = [
|
||||||
A fluid dynamic model
|
A fluid dynamic model
|
||||||
for glacier flow
|
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
|
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.
|
content. In our case, it passes it on to the `columns` function.
|
||||||
|
|
||||||
```example
|
```example:single
|
||||||
>>> #let title = [
|
>>> #let title = [
|
||||||
>>> A fluid dynamic model
|
>>> A fluid dynamic model
|
||||||
>>> for glacier flow
|
>>> for glacier flow
|
||||||
|
@ -125,7 +125,10 @@ previous chapter.
|
|||||||
columns(2, doc)
|
columns(2, doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#show: doc => conf([Paper title], doc)
|
#show: doc => conf(
|
||||||
|
[Paper title],
|
||||||
|
doc,
|
||||||
|
)
|
||||||
|
|
||||||
= Introduction
|
= Introduction
|
||||||
#lorem(90)
|
#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
|
from another file between the `{import}` and `{from}` keywords and specify the
|
||||||
path of the file after the `{from}` keyword.
|
path of the file after the `{from}` keyword.
|
||||||
|
|
||||||
```example
|
```example:single
|
||||||
>>> #let conf(
|
>>> #let conf(
|
||||||
>>> title: none,
|
>>> title: none,
|
||||||
>>> authors: (),
|
>>> authors: (),
|
||||||
|
@ -119,7 +119,7 @@ impl PageNode {
|
|||||||
|
|
||||||
/// How many columns the page has.
|
/// How many columns the page has.
|
||||||
///
|
///
|
||||||
/// ```example
|
/// ```example:single
|
||||||
/// #set page(columns: 2, height: 4.8cm)
|
/// #set page(columns: 2, height: 4.8cm)
|
||||||
/// Climate change is one of the most
|
/// Climate change is one of the most
|
||||||
/// pressing issues of our time, with
|
/// pressing issues of our time, with
|
||||||
@ -341,9 +341,9 @@ impl Debug for PageNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// # Page Break
|
/// # 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
|
||||||
/// ```example
|
/// ```example
|
||||||
|
Loading…
x
Reference in New Issue
Block a user