pub struct ExtensionMark {
pub namespace: String,
pub mark_type: String,
pub attributes: Value,
}Expand description
An extension mark for unsupported or unknown mark types.
When parsing a document with extension marks (e.g., “semantic:citation”), this struct preserves the raw data so it can be:
- Passed through unchanged when saving
- Processed by extension-aware applications
Fields§
§namespace: StringThe extension namespace (e.g., “semantic”, “legal”, “presentation”).
mark_type: StringThe mark type within the namespace (e.g., “citation”, “entity”, “index”).
attributes: ValueExtension-specific attributes.
Implementations§
Source§impl ExtensionMark
impl ExtensionMark
Sourcepub fn new(namespace: impl Into<String>, mark_type: impl Into<String>) -> Self
pub fn new(namespace: impl Into<String>, mark_type: impl Into<String>) -> Self
Create a new extension mark.
Sourcepub fn parse_type(type_str: &str) -> Option<(&str, &str)>
pub fn parse_type(type_str: &str) -> Option<(&str, &str)>
Parse an extension type string like “semantic:citation” into (namespace, mark_type).
Returns None if the type doesn’t contain a colon.
Sourcepub fn is_namespace(&self, namespace: &str) -> bool
pub fn is_namespace(&self, namespace: &str) -> bool
Check if this extension is from a specific namespace.
Sourcepub fn is_type(&self, namespace: &str, mark_type: &str) -> bool
pub fn is_type(&self, namespace: &str, mark_type: &str) -> bool
Check if this is a specific extension type.
Sourcepub fn with_attributes(self, attributes: Value) -> Self
pub fn with_attributes(self, attributes: Value) -> Self
Set the attributes.
Sourcepub fn get_attribute(&self, key: &str) -> Option<&Value>
pub fn get_attribute(&self, key: &str) -> Option<&Value>
Get an attribute value by key.
Sourcepub fn get_string_attribute(&self, key: &str) -> Option<&str>
pub fn get_string_attribute(&self, key: &str) -> Option<&str>
Get a string attribute.
Sourcepub fn get_string_array_attribute(&self, key: &str) -> Option<Vec<&str>>
pub fn get_string_array_attribute(&self, key: &str) -> Option<Vec<&str>>
Get an array-of-strings attribute.
Sourcepub fn get_citation_refs(&self) -> Option<Vec<&str>>
pub fn get_citation_refs(&self) -> Option<Vec<&str>>
Get citation refs, supporting both "refs" (array) and legacy "ref" (string).
Returns None if neither key is present.
Sourcepub fn normalize_citation_attrs(&mut self)
pub fn normalize_citation_attrs(&mut self)
Rewrite legacy "ref" (string) → "refs" (array) in the attributes map.
No-op if "refs" already exists or "ref" is absent.
Sourcepub fn get_glossary_ref(&self) -> Option<&str>
pub fn get_glossary_ref(&self) -> Option<&str>
Get glossary term ref, supporting both "ref" and legacy "termId".
Returns None if neither key is present.
Sourcepub fn normalize_glossary_attrs(&mut self)
pub fn normalize_glossary_attrs(&mut self)
Rewrite legacy "termId" → "ref" in the attributes map.
No-op if "ref" already exists or "termId" is absent.
Sourcepub fn citation(reference: impl Into<String>) -> Self
pub fn citation(reference: impl Into<String>) -> Self
Create a citation mark (semantic extension).
Sourcepub fn citation_with_page(
reference: impl Into<String>,
page: impl Into<String>,
) -> Self
pub fn citation_with_page( reference: impl Into<String>, page: impl Into<String>, ) -> Self
Create a citation mark with page locator.
Sourcepub fn multi_citation(refs: &[String]) -> Self
pub fn multi_citation(refs: &[String]) -> Self
Create a multi-reference citation mark (e.g., [smith2023; jones2024]).
Sourcepub fn entity(uri: impl Into<String>, entity_type: impl Into<String>) -> Self
pub fn entity(uri: impl Into<String>, entity_type: impl Into<String>) -> Self
Create an entity link mark (semantic extension).
Sourcepub fn glossary(term_id: impl Into<String>) -> Self
pub fn glossary(term_id: impl Into<String>) -> Self
Create a glossary reference mark (semantic extension).
Sourcepub fn index_with_subterm(
term: impl Into<String>,
subterm: impl Into<String>,
) -> Self
pub fn index_with_subterm( term: impl Into<String>, subterm: impl Into<String>, ) -> Self
Create an index mark with subterm.
Sourcepub fn equation_ref(target: impl Into<String>) -> Self
pub fn equation_ref(target: impl Into<String>) -> Self
Create an equation reference mark (academic extension).
References an equation by its ID (e.g., “#eq-pythagoras”).
Sourcepub fn equation_ref_formatted(
target: impl Into<String>,
format: impl Into<String>,
) -> Self
pub fn equation_ref_formatted( target: impl Into<String>, format: impl Into<String>, ) -> Self
Create an equation reference mark with custom format.
The format string can use {number} as a placeholder for the equation number.
Sourcepub fn algorithm_ref(target: impl Into<String>) -> Self
pub fn algorithm_ref(target: impl Into<String>) -> Self
Create an algorithm reference mark (academic extension).
References an algorithm by its ID (e.g., “#alg-quicksort”).
Sourcepub fn algorithm_ref_line(
target: impl Into<String>,
line: impl Into<String>,
) -> Self
pub fn algorithm_ref_line( target: impl Into<String>, line: impl Into<String>, ) -> Self
Create an algorithm reference mark with line reference.
References a specific line within an algorithm.
Sourcepub fn algorithm_ref_formatted(
target: impl Into<String>,
format: impl Into<String>,
) -> Self
pub fn algorithm_ref_formatted( target: impl Into<String>, format: impl Into<String>, ) -> Self
Create an algorithm reference mark with custom format.
The format string can use {number} and {line} as placeholders.
Sourcepub fn algorithm_ref_line_formatted(
target: impl Into<String>,
line: impl Into<String>,
format: impl Into<String>,
) -> Self
pub fn algorithm_ref_line_formatted( target: impl Into<String>, line: impl Into<String>, format: impl Into<String>, ) -> Self
Create an algorithm reference mark with line and custom format.
Sourcepub fn theorem_ref(target: impl Into<String>) -> Self
pub fn theorem_ref(target: impl Into<String>) -> Self
Create a theorem reference mark (academic extension).
References a theorem by its ID (e.g., “#thm-pythagoras”).
Sourcepub fn theorem_ref_formatted(
target: impl Into<String>,
format: impl Into<String>,
) -> Self
pub fn theorem_ref_formatted( target: impl Into<String>, format: impl Into<String>, ) -> Self
Create a theorem reference mark with custom format.
The format string can use {number} and {variant} as placeholders.
Sourcepub fn highlight(color: impl Into<String>) -> Self
pub fn highlight(color: impl Into<String>) -> Self
Create a highlight mark (collaboration extension).
Applies a colored highlight to text for collaborative annotation. Default color is yellow if not specified.
Sourcepub fn highlight_yellow() -> Self
pub fn highlight_yellow() -> Self
Create a highlight mark with default yellow color.
Sourcepub fn highlight_colored(color: impl Display) -> Self
pub fn highlight_colored(color: impl Display) -> Self
Create a highlight mark with a specific color.
Convenience method that accepts the HighlightColor display string.
Trait Implementations§
Source§impl Clone for ExtensionMark
impl Clone for ExtensionMark
Source§fn clone(&self) -> ExtensionMark
fn clone(&self) -> ExtensionMark
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExtensionMark
impl Debug for ExtensionMark
Source§impl<'de> Deserialize<'de> for ExtensionMark
impl<'de> Deserialize<'de> for ExtensionMark
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for ExtensionMark
impl PartialEq for ExtensionMark
Source§impl Serialize for ExtensionMark
impl Serialize for ExtensionMark
impl Eq for ExtensionMark
impl StructuralPartialEq for ExtensionMark
Auto Trait Implementations§
impl Freeze for ExtensionMark
impl RefUnwindSafe for ExtensionMark
impl Send for ExtensionMark
impl Sync for ExtensionMark
impl Unpin for ExtensionMark
impl UnsafeUnpin for ExtensionMark
impl UnwindSafe for ExtensionMark
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.