pub struct Config { /* private fields */ }Expand description
Configuration for the termlink preprocessor.
All fields are private to allow future changes without breaking the API. Use the getter methods to access configuration values.
Implementations§
Source§impl Config
impl Config
Sourcepub fn from_context(ctx: &PreprocessorContext) -> Result<Self, TermlinkError>
pub fn from_context(ctx: &PreprocessorContext) -> Result<Self, TermlinkError>
Creates configuration from the preprocessor context.
Unknown display-mode values fall back to the default with a
log::warn!; invalid glob patterns under exclude-pages are dropped
the same way. These are user-typo cases, not hard errors.
§Errors
Returns TermlinkError::BadConfig if [preprocessor.termlink] in
book.toml fails to deserialize.
Sourcepub fn glossary_path(&self) -> &Path
pub fn glossary_path(&self) -> &Path
Returns the path to the glossary file.
Sourcepub const fn link_first_only(&self) -> bool
pub const fn link_first_only(&self) -> bool
Returns true if only the first occurrence of each term should be linked.
Sourcepub const fn case_sensitive(&self) -> bool
pub const fn case_sensitive(&self) -> bool
Returns true if term matching should be case-sensitive.
Sourcepub fn is_glossary_path(&self, path: &Path) -> bool
pub fn is_glossary_path(&self, path: &Path) -> bool
Checks if the given path is the glossary file.
Sourcepub fn should_exclude(&self, path: &Path) -> bool
pub fn should_exclude(&self, path: &Path) -> bool
Checks if the given path should be excluded from term linking.
Sourcepub fn aliases(&self, term_name: &str) -> Option<&Vec<String>>
pub fn aliases(&self, term_name: &str) -> Option<&Vec<String>>
Returns aliases for a term name (if configured).
Sourcepub fn split_pattern(&self) -> Option<&str>
pub fn split_pattern(&self) -> Option<&str>
Returns the split delimiter for glossary definitions, if configured.
Sourcepub const fn display_mode(&self) -> DisplayMode
pub const fn display_mode(&self) -> DisplayMode
Returns how linked terms should be rendered.
Sourcepub const fn process_glossary(&self) -> bool
pub const fn process_glossary(&self) -> bool
Returns true if the glossary page itself should be processed.
When true, term usages in the glossary page’s prose and inside other
terms’ definitions are linkified (with same-page #anchor hrefs), but
the definition-list titles are left untouched so a term never
self-links.