#[non_exhaustive]pub struct OptionsBuilder<'a> { /* private fields */ }Expand description
Builder for Options that provides an API for configuration.
Create an OptionsBuilder using Options::builder().
§Example
use acdc_parser::{Options, SafeMode};
let options = Options::builder()
.with_safe_mode(SafeMode::Safe)
.with_timings()
.with_attribute("toc", "left")
.with_attribute("sectnums", true)
.build()?;Implementations§
Source§impl<'a> OptionsBuilder<'a>
impl<'a> OptionsBuilder<'a>
Sourcepub fn with_safe_mode(self, safe_mode: SafeMode) -> Self
pub fn with_safe_mode(self, safe_mode: SafeMode) -> Self
Set the safe mode for parsing.
§Example
use acdc_parser::{Options, SafeMode};
let options = Options::builder()
.with_safe_mode(SafeMode::Safe)
.build()?;Sourcepub fn with_timings(self) -> Self
pub fn with_timings(self) -> Self
Enable timing information during parsing.
§Example
use acdc_parser::Options;
let options = Options::builder()
.with_timings()
.build()?;Sourcepub fn with_include_loader(self, include_loader: IncludeLoader) -> Self
pub fn with_include_loader(self, include_loader: IncludeLoader) -> Self
Select how the parser loads include sources.
Defaults to IncludeLoader::System. The default Secure mode prevents
include reads even when a provider is supplied. Use IncludeLoader::Disabled
to disable loading in lower modes, or IncludeLoader::custom to supply
sources from an editor overlay, virtual filesystem, or custom transport.
§Example
use acdc_parser::{IncludeLoader, Options, SafeMode};
let options = Options::builder()
.with_safe_mode(SafeMode::Safe)
.with_include_loader(IncludeLoader::System)
.build()?;Sourcepub fn with_max_total_include_bytes(self, bytes: usize) -> Self
pub fn with_max_total_include_bytes(self, bytes: usize) -> Self
Set the total selected include text allowed per parse, in bytes.
Defaults to 64 MiB. Each selection counts after indent=, plus one byte
for a separating newline if the text is not empty. This count precedes
nested processing and removal of comments and inactive conditionals.
Nested and repeated includes share the limit. The entry text does not count.
Zero permits only empty selections. Document attributes cannot change this limit. The 10 MiB per-include limit and safe-mode permissions still apply.
§Example
use acdc_parser::{Options, SafeMode};
let options = Options::builder()
.with_safe_mode(SafeMode::Safe)
.with_max_total_include_bytes(256 * 1024 * 1024)
.build()?;Sourcepub fn with_base_dir(self, base_dir: impl AsRef<Path>) -> Self
pub fn with_base_dir(self, base_dir: impl AsRef<Path>) -> Self
Set the directory used to resolve relative includes from the entry input.
Only takes effect when include loading is enabled. For file input this overrides the entry file’s parent directory. For string or reader input it overrides the current working directory. Nested includes remain relative to the file that contains them.
Sourcepub fn with_strict(self) -> Self
pub fn with_strict(self) -> Self
Reject manpage titles that do not use the name(volume) form.
Other recoverable problems still produce warnings.
§Example
use acdc_parser::Options;
let options = Options::builder()
.with_strict()
.build()?;Sourcepub fn with_attribute(
self,
name: impl Into<Cow<'a, str>>,
value: impl Into<AttributeValue<'a>>,
) -> Self
pub fn with_attribute( self, name: impl Into<Cow<'a, str>>, value: impl Into<AttributeValue<'a>>, ) -> Self
Supply an application attribute.
Application values take precedence over document entries, subject to the attribute’s standard assignment rules.
This is a convenience method that accepts various types for the value:
&strbecomesAttributeValue::StringboolbecomesAttributeValue::Bool()becomesAttributeValue::None
§Example
use acdc_parser::Options;
let options = Options::builder()
.with_attribute("toc", "left")
.with_attribute("sectnums", true)
.build()?;Sourcepub fn with_attributes<N, V>(
self,
attributes: impl IntoIterator<Item = (N, V)>,
) -> Self
pub fn with_attributes<N, V>( self, attributes: impl IntoIterator<Item = (N, V)>, ) -> Self
Replace the application-supplied attributes.
Sourcepub fn with_defaults<N, V>(
self,
defaults: impl IntoIterator<Item = (N, V)>,
) -> Self
pub fn with_defaults<N, V>( self, defaults: impl IntoIterator<Item = (N, V)>, ) -> Self
Replace defaults for attributes not supplied by the application.
Document entries can replace these defaults when the attribute permits it. Intrinsic backend values retain their normal precedence. Backend, base backend, file type, and document type defaults also determine their convenience attributes when the options are built.
Sourcepub fn with_default_attribute(
self,
name: impl Into<Cow<'a, str>>,
value: impl Into<AttributeValue<'a>>,
) -> Self
pub fn with_default_attribute( self, name: impl Into<Cow<'a, str>>, value: impl Into<AttributeValue<'a>>, ) -> Self
Supply a default without changing an application override.
Sourcepub fn attribute(&self, name: &str) -> Option<&AttributeValue<'a>>
pub fn attribute(&self, name: &str) -> Option<&AttributeValue<'a>>
Inspect a supplied override or default before validation.