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]

Creates a parser

Creates a parser with options from a book configuration file

Enable/disable HTML as text

Sets a parser's source file

Parse a file and returns an AST or an error

Parse a string and returns an AST an Error.

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)

Returns the list of features used by this parser