pub enum MarkupLanguage {
    Markdown,
    RestructuredText,
    Html,
    Txt,
    Unknown,
    None,
}
Expand description

The Markup language of the note content.

Variants§

§

Markdown

§

RestructuredText

§

Html

§

Txt

§

Unknown

We can not determine the markup language, but confirm that this is a Tp-Note file.

§

None

This is not a Tp-Note file.

Implementations§

If Self is None return rhs, otherwise return Self.

Examples found in repository?
src/note.rs (line 487)
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
    pub fn render_content_to_html(
        &self,
        // We need the file extension to determine the
        // markup language.
        file_ext: &str,
        // HTML template for this rendition.
        tmpl: &str,
    ) -> Result<String, NoteError> {
        // Deserialize.

        // Render Body.
        let input = self.content.body();

        // If this variable is set, overwrite `file_ext`
        let fm_file_ext = match self.context.get(TMPL_VAR_FM_FILE_EXT) {
            Some(tera::Value::String(fm_file_ext)) => fm_file_ext.as_str(),
            _ => "",
        };

        // Render the markup language.
        let html_output = match MarkupLanguage::from(fm_file_ext).or(MarkupLanguage::from(file_ext))
        {
            #[cfg(feature = "renderer")]
            MarkupLanguage::Markdown => Self::render_md_content(input),
            #[cfg(feature = "renderer")]
            MarkupLanguage::RestructuredText => Self::render_rst_content(input)?,
            MarkupLanguage::Html => input.to_string(),
            _ => Self::render_txt_content(input),
        };

        let mut html_context = self.context.clone();

        // Register rendered body.
        html_context.insert(TMPL_HTML_VAR_NOTE_BODY_HTML, &html_output);

        // Insert the raw CSS
        html_context.insert(
            TMPL_HTML_VAR_NOTE_CSS,
            &LIB_CFG.read().unwrap().tmpl_html.css,
        );
        // Insert the web server path to get the CSS loaded.
        html_context.insert(
            TMPL_HTML_VAR_NOTE_CSS_PATH,
            TMPL_HTML_VAR_NOTE_CSS_PATH_VALUE,
        );

        let mut tera = Tera::default();
        tera.extend(&TERA)?;
        let html = tera.render_str(tmpl, &html_context).map_err(|e| {
            note_error_tera_template!(e, "[html_tmpl] viewer/exporter_tmpl ".to_string())
        })?;

        Ok(html)
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Is file_extension listed in one of the known file extension lists?

Is file_extension listed in one of the known file extension lists?

This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

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
Compare self to key and return true if they are equal.

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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.