pub struct Note {
    pub context: Context,
    pub content: Content,
    pub rendered_filename: PathBuf,
}
Expand description

Represents a note.

Fields

context: Context

Captured environment of Tp-Note that is used to fill in templates.

content: Content

The full text content of the note, including its front matter.

rendered_filename: PathBuf
  1. The Content’s header is deserialized into FrontMatter.
  2. FrontMatter is stored in Context with some environment data.
  3. Context data is filled in some filename template.
  4. The result is stored in rendered_filename. This field equals to PathBuf::new() until self.render_filename is called.

Implementations

Constructor, that creates a memory representation of an existing note on disk.

Constructor that creates a new note by filling in the content template template.

Applies a Tera template to the notes context in order to generate a sanitized filename that is in sync with the note’s meta data stored in its front matter.

Checks if self.rendered_filename is taken already. If yes, some copy counter is appended/incremented. Contract: render_filename must have been executed before.

Checks if alt_path is equal to self.rendered_filename without considering their copy counter. If they are similar, self.rendered_filename becomes alt_path. If they are different, then we continue incrementing the copy counter in self.rendered_filename until we find a free spot. (Same as in set_next_unused_rendered_filename()). Contract: render_filename must have been executed before.

Writes the note to disk using the note’s content and the note’s rendered_filename.

Rename the file from_path to self.rendered_filename. Silently fails is source and target are identical. Contract: render_filename must have been executed before.

Write the note to disk and remove the file at the previous location. Similar to rename_from(), but the target is replaced by self.content. Silently fails is source and target are identical. Contract: render_filename must have been executed before.

Renders self into HTML and saves the result in export_dir. If export_dir is the empty string, the directory of note_path is used. - dumps the rendition to STDOUT. This function reads self.rendered_filename or - if empty - self.context.path is used to determine the filename of the html rendition.

First, determines the markup language from the file extension or the fm_file_ext YAML variable, if present. Then calls the appropriate markup renderer. Finally the result is rendered with the HTML_VIEWER_TMPL template.

When the header can not be deserialized, the content is rendered as “Error HTML page”.

Trait Implementations

Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.