Adds separate functions for yaml header and yaml file

master
Jonathan Hodgson 4 years ago
parent 51ca57da7f
commit ccbb335ec4
  1. 21
      inc/yaml

@ -8,14 +8,31 @@ getYamlBlock(){
# If there is a yaml file, use it # If there is a yaml file, use it
# if not, try and get the yaml header # if not, try and get the yaml header
getYamlFile || getYamlHeader
}
getYamlFile(){
vecho "getYamlFile $*"
cd "$dataDir" || return
local filename
filename="$(findFile "$1")"
if [ -f "$filename.yaml" ]; then if [ -f "$filename.yaml" ]; then
cat "$filename.yaml" cat "$filename.yaml"
return 0
else else
sed -n '1 { /^---/ { :a N; /\n---/! ba; p} }' "$filename" | return 1
sed '1d;$d;s/\t/ /g'
fi fi
} }
getYamlHeader(){
vecho "getYamlHeader $*"
cd "$dataDir" || return
local filename
filename="$(findFile "$1")"
sed -n '1 { /^---/ { :a N; /\n---/! ba; p} }' "$filename" |
sed '1d;$d;s/\t/ /g'
}
getYamlTitle(){ getYamlTitle(){
vecho "getYamlTitle $*" vecho "getYamlTitle $*"
cd "$dataDir" || return cd "$dataDir" || return

Loading…
Cancel
Save