pub struct FrontMatterUtils;Expand description
Utility functions for detecting and handling front matter in Markdown documents
Implementations§
Source§impl FrontMatterUtils
impl FrontMatterUtils
Sourcepub fn has_front_matter_field(content: &str, field_prefix: &str) -> bool
pub fn has_front_matter_field(content: &str, field_prefix: &str) -> bool
Check if a content contains front matter with a specific field
Sourcepub fn get_front_matter_field_value<'a>(
content: &'a str,
field_name: &str,
) -> Option<&'a str>
pub fn get_front_matter_field_value<'a>( content: &'a str, field_name: &str, ) -> Option<&'a str>
Get the value of a specific front matter field
Sourcepub fn extract_front_matter_fields(content: &str) -> HashMap<String, String>
pub fn extract_front_matter_fields(content: &str) -> HashMap<String, String>
Extract all front matter fields as a HashMap
Sourcepub fn extract_front_matter<'a>(content: &'a str) -> Vec<&'a str>
pub fn extract_front_matter<'a>(content: &'a str) -> Vec<&'a str>
Extract the front matter content as a vector of lines
Sourcepub fn detect_front_matter_type(content: &str) -> FrontMatterType
pub fn detect_front_matter_type(content: &str) -> FrontMatterType
Detect the type of front matter in the content
Sourcepub fn get_front_matter_end_line(content: &str) -> usize
pub fn get_front_matter_end_line(content: &str) -> usize
Get the line number where front matter ends (or 0 if no front matter)
Re-scans the whole content. LintContext::new calls this once per
document and caches the result; everything downstream of a
LintContext must read ctx.front_matter_end_line() instead
(enforced via disallowed-methods in clippy.toml).
Sourcepub fn separator_pos_outside_quoted_key(
line: &str,
separator: char,
) -> Option<usize>
pub fn separator_pos_outside_quoted_key( line: &str, separator: char, ) -> Option<usize>
Byte position of separator outside a leading quoted key: a quoted
key ("og:title":, "a=b" =) may contain the separator character,
so the search starts after the closing quote.
Sourcepub fn toml_root_key(raw: &str) -> &str
pub fn toml_root_key(raw: &str) -> &str
The top-level key a raw TOML key expression defines. A quoted key is
atomic ("a.b" defines a.b); otherwise the root of a dotted path
(params.seo defines params).