mikeleonard
2/20/2005 5:55:00 PM
Hello all,
I'm very new to Ruby, so appy-polly-loggies in advance if the answer to
this is obvious.
I have a file, qbf.yml, the contents of which are:
----------------qbf.yml----------------
title: "on dogs and foxes"
author: "q.b. foks, esq."
text: "the quick brown
fox jumps
over
the lazy dog"
---------------------------------------
I want to import it into a Ruby hash and use RedCloth to convert the
"text" portion to html. The code I'm using is this:
----------------qbf.rb----------------
require 'yaml'
require 'redcloth'
qbf=YAML::load(File.open('qbf.yml'))
puts RedCloth.new(qbf["text"]).to_html
--------------------------------------
The output I get from this is:
<p>the quick brown
fox jumps
over
the lazy dog</p>
Whereas, I would like:
<p>the quick brown</p>
<p>fox jumps</p>
<p>over</p>
<p>the lazy dog</p>
It looks like when I import the YAML, my paragraph breaks get eaten up.
I'd like to avoid this if at all possible. I'm sure the solution is
very simple, but I can't seem to get my head around it. Any help would
be greatly appreciated.
Thanks in advance,
Mike Leonard