From 9d5f038dade8e5c897b0e61cb14ec60e42d9c373 Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sat, 19 Apr 2025 11:28:56 -0400 Subject: [PATCH] Skip newlines and YAML metadata at the beginning of a markdown file --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index d8d0bbe..71f9afa 100755 --- a/build.sh +++ b/build.sh @@ -91,7 +91,7 @@ del_files_in_output() { read_metadata() { # Read the metadata from the top of a .md file into a string - metadata=$(awk 'BEGIN{RS = "\n\n"} {print $0}; {exit}' "$1") # Reads from the .md file until a double-newline is encountered + metadata=$(awk 'BEGIN{RS = "\n\n"} ($0 != "") && ($0 !~ /^---/) {print $0; exit}' "$1") # Reads from the .md file until a double-newline is encountered, as long as 1) the text read is non-empty and 2) it doesn't start with a triple hyphen (the triple hyphen denotes a pandoc metadata block) } convert_to_array() {