pub enum ContentFormat {
Markdown,
Djot,
Html,
}Expand description
Which body-prose grammar a document is written in. Maps to a twig
twig::Format one-to-one; kept as prov’s own type so callers can name
a format without depending on twig directly, e.g. for the content_format
config knob.
Variants§
Implementations§
Source§impl ContentFormat
impl ContentFormat
Sourcepub fn from_extension(path: &Path) -> Option<Self>
pub fn from_extension(path: &Path) -> Option<Self>
Infer the content format from a path’s extension. None for anything
unrecognized (including config extensions, which have no body).
Sourcepub fn extension(self) -> &'static str
pub fn extension(self) -> &'static str
The canonical file extension for this grammar (no leading dot) — what a
freshly authored document’s filename gets when prov derives a name
from a title (prov new "A Title"). The inverse of the primary
from_extension spelling.
Sourcepub fn as_config_str(self) -> &'static str
pub fn as_config_str(self) -> &'static str
The content_format config-document spelling for this grammar.
Sourcepub fn from_config_str(value: &str) -> Option<Self>
pub fn from_config_str(value: &str) -> Option<Self>
Parse a content_format config value. Unknown → None (keep default).
Sourcepub fn is_lossy_to(self, other: Self) -> bool
pub fn is_lossy_to(self, other: Self) -> bool
Whether transcoding between self and other loses authored
structure badly enough to need an explicit --force.
HTML is the lossy endpoint, in both directions. Into HTML is a one-way
trip: the result is a rendering, and the Markdown or Djot the author wrote
— the #, the _emph_, the fence — is gone from the file, recoverable
only by re-deriving a guess at it. Out of HTML is that trip run
backwards, and everything HTML carries that a prose grammar has no spelling
for (attributes, nested inline markup, whole elements) survives only as a
raw-HTML escape, or not at all.
Markdown ↔ Djot is deliberately not gated: twig re-spells emphasis,
headings and raw HTML into the target grammar and carries footnotes,
tables, code fences and [[wikilinks]] through intact. The one wart is a
reference-style link, which is inlined ([x][ref] → [x](notes/b.md)),
leaving its now-unused [ref]: definition behind — untidy, but nothing a
reader loses.
Trait Implementations§
Source§impl Clone for ContentFormat
impl Clone for ContentFormat
Source§fn clone(&self) -> ContentFormat
fn clone(&self) -> ContentFormat
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ContentFormat
Source§impl Debug for ContentFormat
impl Debug for ContentFormat
impl Eq for ContentFormat
Source§impl PartialEq for ContentFormat
impl PartialEq for ContentFormat
impl StructuralPartialEq for ContentFormat
Auto Trait Implementations§
impl Freeze for ContentFormat
impl RefUnwindSafe for ContentFormat
impl Send for ContentFormat
impl Sync for ContentFormat
impl Unpin for ContentFormat
impl UnsafeUnpin for ContentFormat
impl UnwindSafe for ContentFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.