kramdown
kramdown copied to clipboard
Unable to decode HTML entities
I want to convert HTML to plain text within a Kramdown plugin I'm making and I'm unable to get HTML entities decoded no matter what I do. Here's one of many things I've tried:
html = "<h1>& > <</h1>"
doc = Kramdown::Document.new(html, input: :html, entity_output: :as_char)
puts doc.to_kramdown # Outputs: # & > <
I expected the output to be # & > <
and not # & > <
. What am I doing wrong here?
You are doing nothing wrong, this is just how the conversion is done. The entities for < > & "
are not converted to characters.
Thanks for the quick reply! Would it be possible to change that behavior, somehow?
I'm open to pull requests that adjust this behaviour in the kramdown converter, the used utility function should not be changed because it is used in several places.
Thanks, @gettalong. I may have a look at this when time allows. For now, I've circumvented the issue by using REXML directly.