I have a simple Markdown file with YAML header that looks something like this:
---
title: "Mary had a little lamb"
link: http://google.com
---
I want to extract some of the YAML data to use later in a workflow. So far I have this but it just gives me errors. Ideally once I extract the title key I would also like to strip the quotation marks but not sure how to do that yet either. Maybe there is an easier way?
#coding: utf-8
import console
import yaml
import editor
from StringIO import StringIO
text = StringIO(editor.get_text())
doc = list(yaml.load_all(text))
tweet_link = doc["link"]
tweet_title = doc["title"]
console.hud_alert(tweet_link)