I'm looking for a way to translate an html
file to a Markdown
type syntax. That's the request from my client. They think that this type of archival method is good for manipulation into one of their GUI apps, while maintaining the ability to edit with an acceptable amount of retained markup.
I'm looking at Kramdown
, but it's confusing. I have created a Kramdown
object imported from the html
file:
doc = Kramdown::Document.new(source, :input => 'html')
I'd like to output the Kramdown
format, but I don't understand how to save it as a Kramdown
format.
Is there a way to save the file with the Kramdown
format? The original html
file is parsed into Kramdown
, now I want to save that file much like how I would a Markdown
file, with that simple markup syntax. This works just fine:
puts doc.to_html
...so doc
is just fine. I just need a way to output the Kramdown
version. Any insight appreciated. Cheers
You need the
to_kramdown
method. It’s not documented directly as it is dynamically called, but seemethod_missing
.