Module: SolrEad::Formatting

Included in:
Behaviors, Component, Document
Defined in:
lib/solr_ead/formatting.rb

Constant Summary collapse

RENDER_ATTRS =
{
   "altrender"       => "em",
   "bold"            => "strong",
   "doublequote"     => "em",
   "bolddoublequote" => "strong",
   "bolditalic"      => "strong",
   "boldsinglequote" => "strong",
   "boldsmcaps"      => "strong",
   "boldunderline"   => "strong",
   "italic"          => "em",
   "italics"         => "em",
   "nonproport"      => "em",
   "singlequote"     => "em",
   "smcaps"          => "em",
   "sub"             => "sub",
   "super"           => "sup",
   "underline"       => "em"
}

Instance Method Summary collapse

Instance Method Details

#ead_to_html(xml) ⇒ Object

Use this method convert the xml directly



32
33
34
# File 'lib/solr_ead/formatting.rb', line 32

def ead_to_html xml
  ::Sanitize.clean(transform_render_attributes(xml), :elements => RENDER_ATTRS.values.uniq )
end

#term_to_html(term) ⇒ Object

If you’re within the context of an OM::XML::Document, you can just pass the term you want converted and this will get the xml using the term.



27
28
29
# File 'lib/solr_ead/formatting.rb', line 27

def term_to_html term
  ead_to_html self.send(term).nodeset.to_xml
end