Enum MarkupLanguage

Source
#[non_exhaustive]
pub enum MarkupLanguage { Markdown, ReStructuredText, Html, PlainText, RendererDisabled, Unkown, None, }
Expand description

The Markup language of the note content.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Markdown

§

ReStructuredText

§

Html

§

PlainText

§

RendererDisabled

The markup language is known, but the renderer is disabled.

§

Unkown

This is a Tp-Note file, but we are not able to determine the MarkupLanguage at this point.

§

None

This is not a Tp-Note file.

Implementations§

Source§

impl MarkupLanguage

Source

pub fn or(self, rhs: Self) -> Self

If Self is None return rhs, otherwise return Self.

Source

pub fn mine_type(&self) -> Option<&'static str>

Returns the MIME type for all Markup Languages.is_tpnote_file()==true. Otherwise, for MarkupLanguage::None this returns None.

Source

pub fn is_some(&self) -> bool

As we identify a markup language by the file’s extension, we can also tell, in case Markuplanguage::from(ext).is_some(), that a file with the extension ext is a Tp-Note file.

Source

pub fn is_none(&self) -> bool

As we identify a markup language by the file’s extension, we can also tell, in case Markuplanguage::from(ext).is_none(), that a file with the extension ext is NOT a Tp-Note file.

Source

pub fn render(&self, input: &str) -> String

Every MarkupLanguage variant has an own internal HTML renderer:

  • Markdown is rendered according the “CommonMark” standard.
  • Currently only as small subset of ReStructuredText is rendered for ReStructuredText. This feature is experimental.
  • The Html renderer simply forwards the input without modification.
  • PlainText is rendered as raw text. Hyperlinks in Markdown, ReStructuredText, AsciiDoc and WikiText syntax are detected and are displayed in the rendition with their link text. All hyperlinks are clickable.
  • Unknown is rendered like PlainText, hyperlinks are also clickable, but they are displayed as they appear in the input.
  • For the variant None the result is always the empty string whatever the input may be.

Trait Implementations§

Source§

impl Clone for MarkupLanguage

Source§

fn clone(&self) -> MarkupLanguage

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 Debug for MarkupLanguage

Source§

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

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

impl Default for MarkupLanguage

Source§

fn default() -> MarkupLanguage

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

impl<'de> Deserialize<'de> for MarkupLanguage

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 From<&Path> for MarkupLanguage

Source§

fn from(path: &Path) -> Self

Is the file extension at the end of the given path listed infile.extensions? Return the corresponding MarkupLanguage. Only the extension of Path` is considered here.

Source§

impl From<&str> for MarkupLanguage

Source§

fn from(file_extension: &str) -> Self

Is file_extension listed in file.extensions?

Source§

impl Hash for MarkupLanguage

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MarkupLanguage

Source§

fn eq(&self, other: &MarkupLanguage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for MarkupLanguage

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
Source§

impl Copy for MarkupLanguage

Source§

impl Eq for MarkupLanguage

Source§

impl StructuralPartialEq for MarkupLanguage

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,