pub fn parse_lino_with_config(
document: &str,
config: &ParserConfig,
) -> Result<LiNo<String>, ParseError>Expand description
Reads a document the way config says to.
ยงExamples
use links_notation::{parse_lino_with_config, ParserConfig};
let document = "# a: b";
assert_eq!(
format!("{}", parse_lino_with_config(document, &ParserConfig::new()).unwrap()),
"()"
);
assert!(parse_lino_with_config(document, &ParserConfig::without_comments()).is_err());Examples found in repository?
examples/comments.rs (line 29)
9fn main() {
10 let documents = [
11 "# a note about the document\ndeploy: staging\n",
12 "deploy: staging # only staging, for now\n",
13 "issue#1047: open\n",
14 "\"# not a comment\": still a reference\n",
15 "parent\n # what the child is for\n child\n",
16 ];
17
18 for document in documents {
19 match parse_lino(document) {
20 Ok(links) => println!("{document:?}\n parses as {links}"),
21 Err(error) => println!("{document:?}\n {error}"),
22 }
23 }
24
25 // Documents that predate comments can be read with `#` as an ordinary
26 // character.
27 let config = ParserConfig::without_comments();
28 let document = "# a b\n";
29 match parse_lino_with_config(document, &config) {
30 Ok(links) => println!("\nwithout comments {document:?}\n parses as {links}"),
31 Err(error) => println!("\nwithout comments {document:?}\n {error}"),
32 }
33}