mirror of
https://github.com/typst/typst
synced 2025-08-14 23:18:32 +08:00
Compare commits
3 Commits
0214320087
...
95a7e28e25
Author | SHA1 | Date | |
---|---|---|---|
|
95a7e28e25 | ||
|
37bb632d2e | ||
|
24b2f98bf9 |
@ -78,7 +78,8 @@ impl PackageStorage {
|
|||||||
self.package_path.as_deref()
|
self.package_path.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Make a package available in the on-disk.
|
/// Makes a package available on-disk and returns the path at which it is
|
||||||
|
/// located (will be either in the cache or package directory).
|
||||||
pub fn prepare_package(
|
pub fn prepare_package(
|
||||||
&self,
|
&self,
|
||||||
spec: &PackageSpec,
|
spec: &PackageSpec,
|
||||||
@ -111,7 +112,7 @@ impl PackageStorage {
|
|||||||
Err(PackageError::NotFound(spec.clone()))
|
Err(PackageError::NotFound(spec.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to determine the latest version of a package.
|
/// Tries to determine the latest version of a package.
|
||||||
pub fn determine_latest_version(
|
pub fn determine_latest_version(
|
||||||
&self,
|
&self,
|
||||||
spec: &VersionlessPackageSpec,
|
spec: &VersionlessPackageSpec,
|
||||||
@ -144,7 +145,7 @@ impl PackageStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Download the package index. The result of this is cached for efficiency.
|
/// Download the package index. The result of this is cached for efficiency.
|
||||||
pub fn download_index(&self) -> StrResult<&[serde_json::Value]> {
|
fn download_index(&self) -> StrResult<&[serde_json::Value]> {
|
||||||
self.index
|
self.index
|
||||||
.get_or_try_init(|| {
|
.get_or_try_init(|| {
|
||||||
let url = format!("{DEFAULT_REGISTRY}/{DEFAULT_NAMESPACE}/index.json");
|
let url = format!("{DEFAULT_REGISTRY}/{DEFAULT_NAMESPACE}/index.json");
|
||||||
@ -165,7 +166,7 @@ impl PackageStorage {
|
|||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
/// Panics if the package spec namespace isn't `DEFAULT_NAMESPACE`.
|
/// Panics if the package spec namespace isn't `DEFAULT_NAMESPACE`.
|
||||||
pub fn download_package(
|
fn download_package(
|
||||||
&self,
|
&self,
|
||||||
spec: &PackageSpec,
|
spec: &PackageSpec,
|
||||||
cache_dir: &Path,
|
cache_dir: &Path,
|
||||||
|
@ -94,7 +94,7 @@ pub struct BibliographyElem {
|
|||||||
/// - A path string to load a bibliography file from the given path. For
|
/// - A path string to load a bibliography file from the given path. For
|
||||||
/// more details about paths, see the [Paths section]($syntax/#paths).
|
/// more details about paths, see the [Paths section]($syntax/#paths).
|
||||||
/// - Raw bytes from which the bibliography should be decoded.
|
/// - Raw bytes from which the bibliography should be decoded.
|
||||||
/// - An array where each item is one the above.
|
/// - An array where each item is one of the above.
|
||||||
#[required]
|
#[required]
|
||||||
#[parse(
|
#[parse(
|
||||||
let sources = args.expect("sources")?;
|
let sources = args.expect("sources")?;
|
||||||
|
@ -388,7 +388,7 @@ pub struct OutlineEntry {
|
|||||||
/// space between the entry's body and the page number. When using show
|
/// space between the entry's body and the page number. When using show
|
||||||
/// rules to override outline entries, it is thus recommended to wrap the
|
/// rules to override outline entries, it is thus recommended to wrap the
|
||||||
/// fill in a [`box`] with fractional width, i.e.
|
/// fill in a [`box`] with fractional width, i.e.
|
||||||
/// `{box(width: 1fr, it.fill}`.
|
/// `{box(width: 1fr, it.fill)}`.
|
||||||
///
|
///
|
||||||
/// When using [`repeat`], the [`gap`]($repeat.gap) property can be useful
|
/// When using [`repeat`], the [`gap`]($repeat.gap) property can be useful
|
||||||
/// to tweak the visual weight of the fill.
|
/// to tweak the visual weight of the fill.
|
||||||
|
@ -188,7 +188,7 @@ pub struct RawElem {
|
|||||||
/// - A path string to load a syntax file from the given path. For more
|
/// - A path string to load a syntax file from the given path. For more
|
||||||
/// details about paths, see the [Paths section]($syntax/#paths).
|
/// details about paths, see the [Paths section]($syntax/#paths).
|
||||||
/// - Raw bytes from which the syntax should be decoded.
|
/// - Raw bytes from which the syntax should be decoded.
|
||||||
/// - An array where each item is one the above.
|
/// - An array where each item is one of the above.
|
||||||
///
|
///
|
||||||
/// ````example
|
/// ````example
|
||||||
/// #set raw(syntaxes: "SExpressions.sublime-syntax")
|
/// #set raw(syntaxes: "SExpressions.sublime-syntax")
|
||||||
|
@ -44,7 +44,7 @@ I am #amazed(color: purple)[amazed]!
|
|||||||
Templates now work by wrapping our whole document in a custom function like
|
Templates now work by wrapping our whole document in a custom function like
|
||||||
`amazed`. But wrapping a whole document in a giant function call would be
|
`amazed`. But wrapping a whole document in a giant function call would be
|
||||||
cumbersome! Instead, we can use an "everything" show rule to achieve the same
|
cumbersome! Instead, we can use an "everything" show rule to achieve the same
|
||||||
with cleaner code. To write such a show rule, put a colon directly behind the
|
with cleaner code. To write such a show rule, put a colon directly after the
|
||||||
show keyword and then provide a function. This function is given the rest of the
|
show keyword and then provide a function. This function is given the rest of the
|
||||||
document as a parameter. The function can then do anything with this content.
|
document as a parameter. The function can then do anything with this content.
|
||||||
Since the `amazed` function can be called with a single content argument, we can
|
Since the `amazed` function can be called with a single content argument, we can
|
||||||
|
Loading…
x
Reference in New Issue
Block a user