Struct Pandoc

Source
pub struct Pandoc { /* private fields */ }
Expand description

the argument builder

Implementations§

Source§

impl Pandoc

Source

pub fn new() -> Pandoc

Get a new Pandoc object This function returns a builder object to configure the Pandoc execution.

Source

pub fn add_latex_path_hint<T: AsRef<Path> + ?Sized>( &mut self, path: &T, ) -> &mut Pandoc

Add a path hint to search for the LaTeX executable.

The supplied path is searched first for the latex executable, then the environment variable PATH, then some hard-coded location hints.

Source

pub fn add_pandoc_path_hint<T: AsRef<Path> + ?Sized>( &mut self, path: &T, ) -> &mut Pandoc

Add a path hint to search for the Pandoc executable.

The supplied path is searched first for the Pandoc executable, then the environment variable PATH, then some hard-coded location hints.

Source

pub fn set_doc_class(&mut self, class: DocumentClass) -> &mut Pandoc

Set or overwrite the document-class.

Source

pub fn set_show_cmdline(&mut self, flag: bool) -> &mut Pandoc

Set whether Pandoc should print the used command-line

If set to true, the command-line to execute pandoc (as a subprocess) will be displayed on stdout.

Source

pub fn set_output_format( &mut self, format: OutputFormat, extensions: Vec<MarkdownExtension>, ) -> &mut Pandoc

Set or overwrite the output format.

Source

pub fn set_input_format( &mut self, format: InputFormat, extensions: Vec<MarkdownExtension>, ) -> &mut Pandoc

Set or overwrite the input format

Source

pub fn add_input<T: AsRef<Path> + ?Sized>( &mut self, filename: &T, ) -> &mut Pandoc

Add additional input files

The order of adding the files is the order in which they are processed, hence the order is important. This function does not work, if input has been already set to standard input using set_input.

Source

pub fn set_input(&mut self, input: InputKind) -> &mut Pandoc

Set input for Pandoc.

The input is given with pandoc::InputKind and overrides any inputs already supplied.

§Example
// pass in a string using standard input:
let markdown = "**very** _important".into();
let mut p = pandoc::new(); // assign to variable to increase life time
p.set_input(pandoc::InputKind::Pipe(markdown));
Source

pub fn set_output(&mut self, output: OutputKind) -> &mut Pandoc

Set or overwrite the output filename.

Source

pub fn set_bibliography<T: AsRef<Path> + ?Sized>( &mut self, filename: &T, ) -> &mut Pandoc

Set the file name of the bibliography database.

Source

pub fn set_csl<T: AsRef<Path> + ?Sized>(&mut self, filename: &T) -> &mut Pandoc

Set the filename of the citation style file.

Source

pub fn set_toc(&mut self) -> &mut Pandoc

Enable the generation of a table of contents

By default, documents are transformed as they are. If this option is set, a table of contents is added right in front of the actual document.

Source

pub fn set_chapters(&mut self) -> &mut Pandoc

Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook output.

Source

pub fn set_number_sections(&mut self) -> &mut Pandoc

Set custom prefix for sections.

If this function is called, all sections will be numbered. Normally, sections in LaTeX, ConTeXt, HTML, or EPUB output are unnumbered.

Source

pub fn set_latex_template<T: AsRef<Path> + ?Sized>( &mut self, filename: &T, ) -> &mut Pandoc

Set a custom latex template.

Source

pub fn set_slide_level(&mut self, level: u32) -> &mut Pandoc

Set the header level that causes a new slide to be generated.

Source

pub fn set_variable<T: AsRef<str> + ?Sized, U: AsRef<str> + ?Sized>( &mut self, key: &T, value: &U, ) -> &mut Pandoc

Set a custom variable.

This method sets a custom Pandoc variable. It is adviced not to use this function, because there are convenience functions for most of the available variables.

Source

pub fn add_filter<F>(&mut self, filter: F) -> &mut Pandoc
where F: 'static + Fn(String) -> String,

Add a Pandoc filter.

Pandoc parses any of the supported input formats to an abstract syntax tree (AST). If a filter is specified, it will receive a JSON representation of this AST and can transform it to its liking and add/modify/remove elements. The output is then passed back to Pandoc.

The provided filter function must live at least as long as the Pandoc instance, which will typically be achieved by making it a function, or else a closure which does not attempt to hold references to anything which isn’t 'static.

Source

pub fn add_option(&mut self, option: PandocOption) -> &mut Pandoc

Add a PandocOption.

Source

pub fn add_options(&mut self, options: &[PandocOption]) -> &mut Pandoc

Source

pub fn arg<T: AsRef<str> + ?Sized, U: AsRef<str> + ?Sized>( &mut self, key: &T, value: &U, ) -> &mut Pandoc

Add a raw command-line argument. You should generally use one of the convenience functions instead.

Source

pub fn generate_latex_template<T: AsRef<str> + ?Sized>(self, filename: &T)

generate a latex template from the given settings

Warning: this function can panic in a lot of places.

Source

pub fn execute(self) -> Result<PandocOutput, PandocError>

Execute the Pandoc configured command.

A successful Pandoc run can return either the path to a file written by the operation, or the result of the operation from stdio.

The PandocOutput variant returned depends on the OutputKind configured:

Trait Implementations§

Source§

impl Clone for Pandoc

Source§

fn clone(&self) -> Pandoc

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for Pandoc

Source§

fn default() -> Pandoc

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

Auto Trait Implementations§

§

impl Freeze for Pandoc

§

impl !RefUnwindSafe for Pandoc

§

impl !Send for Pandoc

§

impl !Sync for Pandoc

§

impl Unpin for Pandoc

§

impl !UnwindSafe for Pandoc

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.