If it works, it works:
TITLE=$(pandoc -t rst f.md -o /dev/null \
-L <(echo "function Meta(m) print(pandoc.utils.stringify(m.title)) end")
)
Works for no quotes and no leading spaces:
TITLE=$(grep -m1 '^title: ' | cut -d' ' -f2)
Needs to unquote, perhaps by piping into sed 's/"//g'
awk -F': ' '/^title: / {print $2; exit}'
Not covering cases where yaml could be in the middle of a markdown file.