File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1- use eyre:: bail;
1+ use eyre:: { ContextCompat , bail} ;
22use serde:: { Deserialize , Serialize } ;
33use toml:: value:: Date ;
44
@@ -21,12 +21,12 @@ pub struct FrontMatter {
2121/// the tuple.
2222pub fn parse ( markdown : & str ) -> eyre:: Result < ( FrontMatter , & str ) > {
2323 if !markdown. starts_with ( "+++\n " ) {
24- bail ! ( "markdown file must start with the line ` +++` " ) ;
24+ bail ! ( "missing start of TOML front matter ( +++) " ) ;
2525 }
2626 let ( front_matter, content) = markdown
2727 . trim_start_matches ( "+++\n " )
2828 . split_once ( "\n +++\n " )
29- . expect ( "couldn't find the end of the front matter: ` +++`" ) ;
29+ . context ( "missing end of TOML front matter ( +++)" ) ? ;
3030
3131 Ok ( ( toml:: from_str ( front_matter) ?, content) )
3232}
@@ -63,7 +63,9 @@ mod tests {
6363
6464 for post in posts {
6565 let content = fs:: read_to_string ( & post) . unwrap ( ) ;
66- let normalized = normalize ( & content) . unwrap ( ) ;
66+ let normalized = normalize ( & content) . unwrap_or_else ( |err| {
67+ panic ! ( "failed to normalize {:?}: {err}" , post. file_name( ) . unwrap( ) ) ;
68+ } ) ;
6769
6870 if content != normalized {
6971 if env:: var ( "FIX_FRONT_MATTER" ) . is_ok ( ) {
You can’t perform that action at this time.
0 commit comments