app/models/proquest_behaviors.rb
# Given text output from tinymce, turn it into something ProQuest can handle
# @param [String] tinymce_output
# @return [String] proquest sanitized text
Given text output from tinymce, turn it into something ProQuest can handle
Given text output from tinymce turn it into something ProQuest can handle
def mce_to_proquest(tinymce_output)
    clean_html = Sanitize.clean(tinymce_output, elements: ['p', 'em', 'b', 'i'])
    proquest_scrubber = Loofah::Scrubber.new do |node|
      if node.name == "img" || node.name == "br"
        node.remove
        Loofah::Scrubber::STOP 
      end
      node.name = "DISS_para" if node.name == "p"
      node.name = "italic" if node.name == "em"
      node.name = "italic" if node.name == "b"
      node.name = "italic" if node.name == "i"
    end
    doc = Loofah.fragment(clean_html).scrub!(:whitewash).scrub!(proquest_scrubber)
    CGI.unescapeHTML(doc.to_s)
  end
def mce_to_proquest ( tinymce_output ) clean_html = Sanitize . clean ( tinymce_output , elements : [ 'p' , 'em' , 'b' , 'i' ] ) proquest_scrubber = Loofah :: Scrubber . new do | node | if node . name == "img" || node . name == "br" node . remove Loofah :: Scrubber :: STOP end node . name = "DISS_para" if node . name == "p" node . name = "italic" if node . name == "em" node . name = "italic" if node . name == "b" node . name = "italic" if node . name == "i" end doc = Loofah . fragment ( clean_html ) . scrub! ( :whitewash ) . scrub! ( proquest_scrubber ) CGI . unescapeHTML ( doc . to_s ) end
Given text output from tinymce, turn it into something ProQuest can handle
Given text output from tinymce turn it into something ProQuest can handle
# don't bother with the rest of the subtree
proquest sanitized text
proquest sanitized text
String
tinymce_output
<not_specific>
<not_specific>
None