I decided to somehow streamline the hackneyed problem: in almost every project I have to make a custom parser that would display the text in a readable form. And in almost every project, 80% of this parser is the solution to already solved problems.
StringParser is a plugin for Rails and Lib, which includes methods that implement the most common parsing tasks. Let me show you by example:
StringParser.new("what a cool url: url.com and image image.com/image.jpg<br/>").urls_to_images.urls_to_links.html_escape.string
The same can be done in the block (this is someone you like more): ')
parser = StringParser.new("what a cool url: url.com and image image.com/image.jpg<br/>") do |p| p.urls_to_images.urls_to_links p.html_escape end parser.string
I will simply give the names of the methods that I have already managed to code, and a more detailed description can be found in the docks or in the source code:
break_long_words close_tags cut highlight_code # uses to highlight gem ultraviolet html_escape # in contrast to the rail equivalent takes: except => [] newlines_to_br urls_to_images urls_to_links
I would like to invite everyone to add and bring to mind.