Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub template_dir: String,
    pub templates: HashMap<String, String>,
    pub keep_typst_files: bool,
    pub template_parameters: HashMap<String, String>,
    pub chapter_imports: Option<String>,
    pub max_width: Option<f64>,
    pub max_height: Option<f64>,
}

Fields§

§template_dir: String

the typst template directory that holds all templates you can reference

§templates: HashMap<String, String>

the list of template name and template file name. this tool will generate a pdf file for each template if no template is provided, it will generate a default pdf file without template.

§keep_typst_files: bool

whether the intermidate typst files for each chapter should be kept or not.

§template_parameters: HashMap<String, String>

parameter and value pairs for template use. you can define your value pair that match your template definition.

§chapter_imports: Option<String>

option multi-lines string that can be imported at the beginning of each chapter. it’s very useful when you want to add the import statements for popular typst external functions.

§max_width: Option<f64>

max_width in a floating number between 0.0 and 1.0 (include). this constraint will only be applied when the max height already meets the requirement.

§max_height: Option<f64>

max_height in a floating number between 0.0 and 1.0 (include).

Implementations§

Source§

impl Config

Source

pub fn get_chapter_full_file_name( &self, chapter: &Chapter, ctx: &RenderContext, ) -> Option<PathBuf>

Source

pub fn get_chapter_relative_chapter_file_name( &self, chapter: &Chapter, _ctx: &RenderContext, ) -> Option<PathBuf>

Source

pub fn append_chapter_to_typst_output( &self, ctx: &RenderContext, typst_output: &mut String, ) -> Result<()>

Source

pub fn convert_book( &self, _chapter_file_list: &mut [PathBuf], ctx: &RenderContext, ) -> Result<()>

Source

pub fn write_typst_file( &self, ctx: &RenderContext, typst_output: &str, template_name: Option<&str>, ) -> Result<()>

Source

pub fn convert_book_to_pdf(&self, ctx: &RenderContext) -> Result<()>

Source

pub fn invoke_typst_command( &self, ctx: &RenderContext, template_name: Option<&str>, ) -> Result<()>

Source§

impl Config

Source

pub fn parse_chapter_content( &self, chapter: &Chapter, content: &str, dst_file_path: &Path, image_parent_dir: &Path, ctx: &RenderContext, ) -> Result<String>

Source

pub fn convert_chapters( &self, chapter_file_list: &mut Vec<PathBuf>, ctx: &RenderContext, ) -> Result<()>

Source§

impl Config

Source§

impl Config

Source

pub fn get_book_name( &self, template_name: Option<&str>, ctx: &RenderContext, ) -> String

Source

pub fn get_template_dir(&self, ctx: &RenderContext) -> PathBuf

Source

pub fn get_typst_dir(&self, ctx: &RenderContext) -> PathBuf

Source

pub fn get_pdf_dir(&self, ctx: &RenderContext) -> PathBuf

Source

pub fn get_typst_templates_dir(&self, ctx: &RenderContext) -> PathBuf

Source

pub fn get_chapters_dir(&self, ctx: &RenderContext) -> PathBuf

Source

pub fn get_output_dir(&self, ctx: &RenderContext) -> PathBuf

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more