
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
This gem adds support for BBCode to Ruby. The BBCode is parsed by a parser before converted to HTML, allowing to convert nested BBCode tags in strings to their correct HTML equivalent. The parser also checks whether the BBCode is valid and gives errors for incorrect BBCode texts. Additionally, annotations can be added to the BBCode string the showing errors that are present, assuming there are any errors.
The parser recognizes all official tags and allows to easily extend this set with custom tags.
bbcode_to_html
can be used to convert a BBCode string to HTML:
'This is [b]bold[/b] and this is [i]italic[/i].'.bbcode_to_html
=> 'This is <strong>bold</strong> and this is <em>italic</em>.'
bbcode_show_errors
can be used to convert a BBCode to BBCode annotated with errors (assuming the original BBCode did contain errors):
'[img=no_dimensions_here]image.png[/img]'.bbcode_show_errors
=> '<span class=\'bbcode_error\' data-bbcode-errors=\'["The image parameters \'no_dimensions_here\' are incorrect, \'<width>x<height>\' excepted"]\'>[img]</span>image.png[/img]'
These HTML attributes containing the JSON representation of the errors can be used to inform the user about the problems. The following JavaScript/jQuery example makes use of the Bootstrap tooltips plugin to show the errors in tooltip popups:
$(".bbcode_error").tooltip({
title: function() {
var errors = JSON.parse($(this).attr('data-bbcode-errors'));
return errors.join("\n");
}
});
Add the following line to the Gemfile of your application:
gem 'ruby-bbcode'
Or to use the source code from the repository:
gem 'ruby-bbcode', :git => 'git://github.com/veger/ruby-bbcode.git'
Run
bundle install
And Ruby-BBCode is available in your application.
Note: Do not forget to restart your server!
A big thanks to @TheNotary for all contributions he made to this project!
Some of the ideas and the tests came from bb-ruby of Craig P Jolicoeur.
MIT License. See the included MIT-LICENCE file.
FAQs
Unknown package
We found that ruby-bbcode demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.