mirror of
https://github.com/typst/typst
synced 2025-06-08 13:16:24 +08:00
Extract finish into custom method
This commit is contained in:
parent
944cd8caae
commit
71e73f9053
@ -15,7 +15,7 @@ use krilla::path::PathBuilder;
|
|||||||
use krilla::surface::Surface;
|
use krilla::surface::Surface;
|
||||||
use krilla::validation::ValidationError;
|
use krilla::validation::ValidationError;
|
||||||
use krilla::version::PdfVersion;
|
use krilla::version::PdfVersion;
|
||||||
use krilla::{PageSettings, SerializeSettings, SvgSettings};
|
use krilla::{Document, PageSettings, SerializeSettings, SvgSettings};
|
||||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -337,6 +337,10 @@ pub fn pdf(
|
|||||||
document.set_outline(build_outline(&gc));
|
document.set_outline(build_outline(&gc));
|
||||||
document.set_metadata(build_metadata(&gc));
|
document.set_metadata(build_metadata(&gc));
|
||||||
|
|
||||||
|
finish(document, gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn finish(document: Document, gc: GlobalContext) -> SourceResult<Vec<u8>> {
|
||||||
match document.finish() {
|
match document.finish() {
|
||||||
Ok(r) => Ok(r),
|
Ok(r) => Ok(r),
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
@ -352,7 +356,7 @@ pub fn pdf(
|
|||||||
// We can only produce 1 error, so just take the first one.
|
// We can only produce 1 error, so just take the first one.
|
||||||
let prefix = format!(
|
let prefix = format!(
|
||||||
"validated export for {} failed:",
|
"validated export for {} failed:",
|
||||||
options.validator.as_str()
|
gc.options.validator.as_str()
|
||||||
);
|
);
|
||||||
match &ve[0] {
|
match &ve[0] {
|
||||||
ValidationError::TooLongString => {
|
ValidationError::TooLongString => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user