1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
// Enable all clippy lints and enforce, and opt out of individual lints #![cfg_attr(feature = "cargo-clippy", warn(clippy::cargo, clippy::pedantic, clippy::nursery))] #![cfg_attr(feature = "cargo-clippy", allow(clippy::must_use_candidate, clippy::non_ascii_literal))] // Force certain lints to be errors #![deny(unused_must_use)] // #![doc(html_root_url = "https://docs.rs/extract-frontmatter/2.0.3")] //! A library that allows a user to extract an arbitrary number of lines of "front-matter" from the start of any multiline string. //! //! Note that absolutely no parsing of extracted front-matter is performed; this is designed to output its results for another library to then parse. //! //! # Usage //! //! To use this library: //! //! 1. Instantiate an instance of [`Extractor`] //! 2. Call a selector method on it //! 3. Call zero or more modifier methods on it //! 4. Call [`extract()`] or [`collect()`] on it //! //! # Example //! //! Given a variable `input` with the following text: //! //! ```md //! root: //! child1: true //! child2: two //! --- //! //! # Example //! //! This is an example Markdown file. //! ``` //! //! ... and the following code: //! //! ```rust //! use extract_frontmatter::Extractor; //! //! # let input = include_str!("../resources/docs/example.md"); //! let mut extractor = Extractor::new(input); //! extractor.select_by_terminator("---"); //! //! let output: String = extractor.extract(); //! # assert_eq!(output, include_str!("../resources/docs/example.yml").trim()); //! ``` //! //! ... the variable `output` will contain: //! //! ```yml //! root: //! child1: true //! child2: two //! ``` //! //! [`Extractor`]: struct.Extractor.html //! [`extract()`]: struct.Extractor.html#method.extract //! [`collect()`]: struct.Extractor.html#method.collect pub use extractor::Extractor; mod extractor; mod modifier; mod selector;