Coder Social home page Coder Social logo

Comments (8)

gucki avatar gucki commented on July 17, 2024

My current workaround is:

class HTMLEntities
  FLAVORS << "xhtml1_customized"

  MAPPINGS["xhtml1_customized"] = MAPPINGS["xhtml1"].dup
  MAPPINGS["xhtml1_customized"].reject!{ |v| ["lt", "gt", "amp"].include?(v) }
end

And then do HTMLEntities.new("xhtml1_customized").decode(string).

from htmlentities.

threedaymonk avatar threedaymonk commented on July 17, 2024

That sounds like a really nice feature. Do you have any ideas about what the interface might ideally look like?

from htmlentities.

gucki avatar gucki commented on July 17, 2024

Not really, but probably something really simple like TMLEntities.new("xhtml1").decode(string, :exclude => ["lt", "gt", "amp"])?

from htmlentities.

Jerska avatar Jerska commented on July 17, 2024

👍 That's the only missing thing in this library.
But I would specify the list the other way around, since for a same character you can have multiple encodings HTMLEntities.new.decode(str, exlude: ['<', '>', '&'])

from htmlentities.

sb4m avatar sb4m commented on July 17, 2024

+1

from htmlentities.

skatiruas avatar skatiruas commented on July 17, 2024

+1

from htmlentities.

zstrad44 avatar zstrad44 commented on July 17, 2024

+1

from htmlentities.

smithtim avatar smithtim commented on July 17, 2024

How about a parameter to only decode "safe" codepoints?

The encode method already makes a distinction between "safe" and "unsafe" codepoints. By default, it only encodes unsafe codepoints:

string = "<élan>"
coder.encode(string) # => "&lt;élan&gt;"

The decode method could take a parameter to only decode safe codepoints:

string = "&lt;&eacute;lan&gt;"
coder.decode(string, :safe) # => "&lt;élan&gt;"

from htmlentities.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.