Skip to content

Commit

Permalink
keep new lines only in the string
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinisukale committed Oct 4, 2023
1 parent 19234e8 commit 3d47a9f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/bolognese/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1057,9 +1057,8 @@ def sanitize(text, options={})
custom_scrubber = Bolognese::WhitelistScrubber.new(options)

if text.is_a?(String)
# Use eval to convert the double-escaped string to the Unicode character
text = eval('"' + text + '"')
Loofah.scrub_fragment(text, custom_scrubber).to_s.strip
# Remove multiple spaces, tabs, and other whitespace characters while preserving single spaces and new lines
Loofah.scrub_fragment(text, custom_scrubber).to_s.gsub(/[ \t]+/, ' ').strip
elsif text.is_a?(Hash)
sanitize(text.fetch(content, nil))
elsif text.is_a?(Array)
Expand Down
2 changes: 1 addition & 1 deletion spec/readers/datacite_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
"descriptionType"=>"SeriesInformation",
"lang"=>"en"},
{"description"=>
"Eating your own dog food is a slang term to \n describe that an organization should itself use the products and services it provides. \n For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...\n • Unicode Bullet Point: This is an example of a bullet point.\n ■ Unicode Black Square: This is an example of a black square.",
"Eating your own dog food is a slang term to \n describe that an organization should itself use the products and services it provides. \n For DataCite this means that we should use DOIs with appropriate metadata and strategies for long-term preservation for...\n • Unicode Bullet Point: This is an example of a bullet point.\\u2605\n ■ Unicode Black Square: This is an example of a black square.",
"descriptionType"=>"Abstract"}])
expect(subject.container).to eq("firstPage"=>"3", "identifier"=>"10.5438/0000-00SS", "identifierType"=>"DOI", "issue"=>"9", "lastPage"=>"4", "title"=>"DataCite Blog", "type"=>"Series", "volume"=>"2")
end
Expand Down

0 comments on commit 3d47a9f

Please sign in to comment.