diff --git a/app/helpers/arclight/ead_format_helpers.rb b/app/helpers/arclight/ead_format_helpers.rb index d40773e59..bea120d0b 100644 --- a/app/helpers/arclight/ead_format_helpers.rb +++ b/app/helpers/arclight/ead_format_helpers.rb @@ -27,6 +27,7 @@ def ead_to_html_scrubber Loofah::Scrubber.new do |node| format_render_attributes(node) if node.attr('render').present? convert_to_span(node) if CONVERT_TO_SPAN_TAGS.include? node.name + convert_to_br(node) if CONVERT_TO_BR_TAG.include? node.name format_links(node) if %w[extptr extref extrefloc ptr ref].include? node.name format_lists(node) if %w[list chronlist].include? node.name node @@ -35,11 +36,17 @@ def ead_to_html_scrubber # Tags that should be converted to tags because of formatting conflicts between XML and HTML CONVERT_TO_SPAN_TAGS = ['title'].freeze + # Tags that should be converted to tags because of formatting conflicts between XML and HTML + CONVERT_TO_BR_TAG = ['lb'].freeze def convert_to_span(node) node.name = 'span' end + def convert_to_br(node) + node.name = 'br' + end + def condense_whitespace(str) str.squish.strip.gsub(/>[\n\s]+<') end diff --git a/spec/helpers/arclight/ead_format_helpers_spec.rb b/spec/helpers/arclight/ead_format_helpers_spec.rb index 15ba65f29..b6e09e027 100644 --- a/spec/helpers/arclight/ead_format_helpers_spec.rb +++ b/spec/helpers/arclight/ead_format_helpers_spec.rb @@ -39,6 +39,11 @@ content = helper.render_html_tags(value: %w[Title]) expect(content).to eq_ignoring_whitespace 'Title' end + + it 'converts tags to
tags' do + content = helper.render_html_tags(value: %w[Myline-break]) + expect(content).to eq_ignoring_whitespace 'My
line-break' + end end describe 'nodes with @render attributes' do