Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to decode HTML entities #734

Open
asbjornu opened this issue Oct 25, 2021 · 4 comments
Open

Unable to decode HTML entities #734

asbjornu opened this issue Oct 25, 2021 · 4 comments

Comments

@asbjornu
Copy link

asbjornu commented Oct 25, 2021

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>&amp; &gt; &lt;</h1>"
doc = Kramdown::Document.new(html, input: :html, entity_output: :as_char)
puts doc.to_kramdown # Outputs: # &amp; &gt; &lt;

I expected the output to be # & > < and not # &amp; &gt; &lt;. What am I doing wrong here?

@gettalong gettalong self-assigned this Oct 25, 2021
@gettalong
Copy link
Owner

You are doing nothing wrong, this is just how the conversion is done. The entities for < > & " are not converted to characters.

@asbjornu
Copy link
Author

asbjornu commented Oct 25, 2021

Thanks for the quick reply! Would it be possible to change that behavior, somehow?

@gettalong
Copy link
Owner

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.

@asbjornu
Copy link
Author

Thanks, @gettalong. I may have a look at this when time allows. For now, I've circumvented the issue by using REXML directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants