Ignoring Symbols #221
-
Is there a way to ignore specific symbols when running |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Without knowing what your input string is, I'm going to make an assumption that your input string contains a bare #! /usr/bin/env ruby
require "nokogiri"
frag = Nokogiri::HTML5.fragment("<div>this & that</div>")
frag.to_html # => "<div>this & that</div>" libxml2 does not allow configuration of how the core HTML entities like Can you tell us a bit more about your use case? Are you trying to sanitize plaintext, or is it truly HTML markup content? If it's plaintext you may be able to use Loofah which provides an opt-in feature that outputs unescaped entities (for example, if you're sending text via SMS you don't want |
Beta Was this translation helpful? Give feedback.
Without knowing what your input string is, I'm going to make an assumption that your input string contains a bare
&
. libxml2 and libgumbo (which underly Nokogiri, which underlies Sanitize) will correct a bare&
to the HTML entity:libxml2 does not allow configuration of how the core HTML entities like
<
,>
, and&
are serialized, which is the right thing to do if you want to emit properly-formed HTML.Can you tell us a bit more about your use case? Are you trying to sanitize plaintext, or is it truly HTML markup content? If it's plaint…