title: Loading document as raw string in yaml with PyYAML
body: <p>I want to parse yaml documents like the following</p>
  
  <pre><code>meta-info-1: val1
  meta-info-2: val2
  
  ---
  
  Plain text/markdown content!
  jhaha
  </code></pre>
  
  <p>If I <code>load_all</code> this with PyYAML, I get the following</p>
  
  <pre><code>&gt;&gt;&gt; list(yaml.load_all(open('index.yml')))
  [{'meta-info-1': 'val1', 'meta-info-2': 'val2'}, 'Plain text/markdown content! jhaha']
  </code></pre>
  
  <p>What I am trying to achieve here is that the yaml file should contain two documents, and the second one is supposed to be interpreted as a single string document, more specifically any large body of text with markdown formatting. I don't want it to be parsed as YAML syntax.</p>
  
  <p>In the above example, PyYAML returns the second document as a single string. But if the second document has a <code>:</code> character in place of the <code>!</code> for instance, I get a syntax error. This is because PyYAML is parsing the stuff in that document.</p>
  
  <p>Is there a way I can tell PyYAML that the second document is a just a raw string and not to parse it?</p>
  
  <p><strong>Edit</strong>: A few excellent answers there. While using quotes or the literal syntax solves the said problem, I'd like the users to be able to write the plain text without any extra cruft. Just the three <code>-</code>'s (or <code>.</code>'s) and write away a large body of plain text. Which might also include quotes too. So, I'd like to know if I can tell PyYAML to parse only one document, and give the second to me raw.</p>
  
  <p><strong>Eidt 2</strong>: So, adapting agf's idea, instead of using a try/except as the second document could be valid yaml syntax,</p>
  
  <pre><code>config_content, body_content = open(filename).read().split('\n---')
  config = yaml.loads(config_content)
  body = yaml.loads(body_content)
  </code></pre>
  
  <p>Thanks agf.</p>