Struct crowbook::ResourceHandler
[−]
[src]
pub struct ResourceHandler<'r> { pub images: HashMap<String, String>, // some fields omitted }
Resource Handler.
Its task is to make sure that some resource (image, link) is available for the book and to list images used in Markdown files so they can be used for the book
Fields
images: HashMap<String, String>
Maps an original (local) file name to a new file name. Allows to
Methods
impl<'r> ResourceHandler<'r>
[src]
fn new(logger: &'r Logger) -> ResourceHandler
Creates a new, empty Resource Handler
fn set_images_mapping(&mut self, b: bool)
Turns on mapping for image files
Argument: an offset (should be book.root)
fn set_base64(&mut self, b: bool)
Sets base64 mode for image mapping
If set to true, instead of returning a destination file path,
map_image
will include the image as base64
fn map_image<'a>(&'a mut self, file: Cow<'a, str>) -> Cow<'a, str>
Add a local image file and get the resulting transformed file name
fn images_mapping(&self) -> &HashMap<String, String>
Returns an iterator the the images files mapping
fn add_link(&mut self, from: String, to: String)
Add a match between an original file and a dest file
fn get_link<'a>(&'a self, from: &'a str) -> &'a str
Get a destination link from an original link
fn is_local(path: &str) -> bool
Tell whether a file name is a local resource or net
fn add_offset(link_offset: &Path, image_offset: &Path, ast: &mut [Token])
Add a path offset to all linked urls and images src