pub struct ReferenceExtractor { /* private fields */ }Expand description
Finds parseable Bible passages embedded in arbitrary prose.
Results are returned from left to right, never overlap, and prefer the longest successful parse beginning at a given byte offset.
Implementations§
Source§impl ReferenceExtractor
impl ReferenceExtractor
Sourcepub fn new() -> ReferenceExtractor
pub fn new() -> ReferenceExtractor
Construct an extractor with a default PassageParser.
Sourcepub fn builder() -> ReferenceExtractorBuilder
pub fn builder() -> ReferenceExtractorBuilder
Start configuring an extractor.
Sourcepub fn from_parser(parser: PassageParser) -> ReferenceExtractor
pub fn from_parser(parser: PassageParser) -> ReferenceExtractor
Construct an extractor around an existing parser.
Sourcepub fn with_options(
parser: PassageParser,
include_bare_books: bool,
max_lookbehind: usize,
max_lookahead: usize,
) -> Result<ReferenceExtractor, ExtractorConfigError>
pub fn with_options( parser: PassageParser, include_bare_books: bool, max_lookbehind: usize, max_lookahead: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>
Construct an extractor from validated configuration values.
Sourcepub const fn parser(&self) -> &PassageParser
pub const fn parser(&self) -> &PassageParser
Return the parser used to validate candidate spans.
Sourcepub const fn include_bare_books(&self) -> bool
pub const fn include_bare_books(&self) -> bool
Return whether whole-book passages are included.
Sourcepub const fn max_lookbehind(&self) -> usize
pub const fn max_lookbehind(&self) -> usize
Return the normalized-byte search distance before numeric anchors.
Sourcepub const fn max_lookahead(&self) -> usize
pub const fn max_lookahead(&self) -> usize
Return the normalized-byte search distance after numeric anchors.
Sourcepub fn with_include_bare_books(self, include: bool) -> ReferenceExtractor
pub fn with_include_bare_books(self, include: bool) -> ReferenceExtractor
Return a copy configured to include or exclude whole-book passages.
Sourcepub fn with_max_lookbehind(
self,
value: usize,
) -> Result<ReferenceExtractor, ExtractorConfigError>
pub fn with_max_lookbehind( self, value: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>
Return a copy with a validated lookbehind window.
Sourcepub fn with_max_lookahead(
self,
value: usize,
) -> Result<ReferenceExtractor, ExtractorConfigError>
pub fn with_max_lookahead( self, value: usize, ) -> Result<ReferenceExtractor, ExtractorConfigError>
Return a copy with a validated lookahead window.
Sourcepub fn extract(&self, source: &str) -> Vec<PassageMatch>
pub fn extract(&self, source: &str) -> Vec<PassageMatch>
Find deterministic, non-overlapping passages in source.
Sourcepub fn extract_with_language(
&self,
source: &str,
language: Language,
) -> Vec<PassageMatch>
pub fn extract_with_language( &self, source: &str, language: Language, ) -> Vec<PassageMatch>
Find passages while resolving book names in one explicit language.
Sourcepub fn find_all(&self, source: &str) -> Vec<PassageMatch>
pub fn find_all(&self, source: &str) -> Vec<PassageMatch>
Alias for Self::extract.
Sourcepub fn find_all_with_language(
&self,
source: &str,
language: Language,
) -> Vec<PassageMatch>
pub fn find_all_with_language( &self, source: &str, language: Language, ) -> Vec<PassageMatch>
Language-specific alias for Self::extract_with_language.
Sourcepub fn replace_matches<F, R>(&self, source: &str, replacement: F) -> String
pub fn replace_matches<F, R>(&self, source: &str, replacement: F) -> String
Replace all matches in one pass without scanning replacement text.
Sourcepub fn replace_matches_with_language<F, R>(
&self,
source: &str,
language: Language,
replacement: F,
) -> String
pub fn replace_matches_with_language<F, R>( &self, source: &str, language: Language, replacement: F, ) -> String
Replace language-specific matches in one pass.
Sourcepub fn linkify<F, R>(&self, source: &str, link_builder: F) -> String
pub fn linkify<F, R>(&self, source: &str, link_builder: F) -> String
Linkify matches with a caller-provided renderer.
Sourcepub fn linkify_with_language<F, R>(
&self,
source: &str,
language: Language,
link_builder: F,
) -> String
pub fn linkify_with_language<F, R>( &self, source: &str, language: Language, link_builder: F, ) -> String
Linkify matches resolved with one explicit language.
Sourcepub fn linkify_markdown<F, U>(&self, source: &str, uri_builder: F) -> String
pub fn linkify_markdown<F, U>(&self, source: &str, uri_builder: F) -> String
Linkify matches as Markdown using each exact source slice as its label.
Sourcepub fn linkify_markdown_with_language<F, U>(
&self,
source: &str,
language: Language,
uri_builder: F,
) -> String
pub fn linkify_markdown_with_language<F, U>( &self, source: &str, language: Language, uri_builder: F, ) -> String
Linkify explicitly localized matches as Markdown using exact source labels.
Sourcepub fn linkify_markdown_with_label<F, U, L>(
&self,
source: &str,
uri_builder: F,
label_builder: L,
) -> String
pub fn linkify_markdown_with_label<F, U, L>( &self, source: &str, uri_builder: F, label_builder: L, ) -> String
Linkify matches as Markdown with caller-provided labels and destinations.
Sourcepub fn linkify_markdown_with_label_and_language<F, U, L>(
&self,
source: &str,
language: Language,
uri_builder: F,
label_builder: L,
) -> String
pub fn linkify_markdown_with_label_and_language<F, U, L>( &self, source: &str, language: Language, uri_builder: F, label_builder: L, ) -> String
Linkify explicitly localized matches with custom Markdown labels.
Sourcepub fn markdown_linkify<F, U>(&self, source: &str, uri_builder: F) -> String
pub fn markdown_linkify<F, U>(&self, source: &str, uri_builder: F) -> String
Alias for Self::linkify_markdown.
Sourcepub fn markdown_linkify_with_language<F, U>(
&self,
source: &str,
language: Language,
uri_builder: F,
) -> String
pub fn markdown_linkify_with_language<F, U>( &self, source: &str, language: Language, uri_builder: F, ) -> String
Language-specific alias for Self::linkify_markdown_with_language.
Trait Implementations§
Source§impl Clone for ReferenceExtractor
impl Clone for ReferenceExtractor
Source§fn clone(&self) -> ReferenceExtractor
fn clone(&self) -> ReferenceExtractor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more