Struct crowbook::Parser [] [src]

pub struct Parser { /* fields omitted */ }

A parser that reads markdown and convert it to AST (a vector of Tokens)

This AST can then be used by various renderes.

As this Parser uses Pulldown-cmark's one, it should be able to parse most valid CommonMark variant of Markdown.

Compared to other Markdown parser, it might fail more often on invalid code, e.g. footnotes references that are not defined anywhere.

Examples

use crowbook::Parser;
let mut parser = Parser::new();
let result = parser.parse("Some *valid* Markdown[^1]\n\n[^1]: with a valid footnote");
assert!(result.is_ok());
use crowbook::Parser;
let mut parser = Parser::new();
let result = parser.parse("Some footnote pointing to nothing[^1] ");
assert!(result.is_err());

Methods

impl Parser
[src]

[src]

Creates a parser

[src]

Creates a parser with options from a book configuration file

[src]

Enable/disable HTML as text

[src]

Sets a parser's source file

[src]

Parse a file and returns an AST or an error

[src]

Parse a string and returns an AST an Error.

[src]

Parse an inline string and returns a list of Token.

This function removes the outermost Paragraph in most of the cases, as it is meant to be used for an inline string (e.g. metadata)

[src]

Returns the list of features used by this parser

Trait Implementations

Auto Trait Implementations

impl Send for Parser

impl Sync for Parser