Skip to main content

parse_from_reader

Function parse_from_reader 

Source
pub fn parse_from_reader<R: Read>(
    reader: R,
    options: &Options<'_>,
) -> Result<ParseResult, Error>
Expand description

Parse AsciiDoc content from a reader.

This function reads the content from the provided reader and parses it as AsciiDoc. The default SafeMode::Secure turns include directives into links without reading their targets. To load includes, select a lower safe mode and enable Options::include_loader.

§Example

use acdc_parser::{Options, SafeMode, parse_from_reader};
use std::io::Cursor;

let options = Options::builder()
    .with_safe_mode(SafeMode::Unsafe)
    .build()?;
let reader = Cursor::new("= Example\n\nContent.\n");
let parsed = parse_from_reader(reader, &options)?;
assert!(!parsed.document().blocks.is_empty());

§Errors

Returns an error if the reader fails, input decoding or preprocessing fails, or the document cannot be parsed. Recoverable problems appear in the result’s warnings.