Skip newlines and YAML metadata at the beginning of a markdown file

master
Aadhavan Srinivasan 7 days ago
parent afccdc5463
commit 9d5f038dad

@ -91,7 +91,7 @@ del_files_in_output() {
read_metadata() { read_metadata() {
# Read the metadata from the top of a .md file into a string # 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() { convert_to_array() {

Loading…
Cancel
Save