Html2Bbcode Build Status

The library for converting the HTML code into the BBCode.

Installation

Install the gem manually:

gem install html2bbcode

or add it into your Gemfile:

gem 'html2bbcode'

Usage

Basic usage:

The given code:

Html2Bbcode.new('normal <b> bolded words <i> italic and bolded </i> bolded </b> normal').convert

Will produce the following output:

'normal [b] bolded words [i] italic and bolded [/i] bolded [/b] normal'

Customizing the font size unit

You can specify the font size unit, used in your BBCode, simply using the size_unit option:

Html2Bbcode.new('<span style="font-size: 15cm;">text 15 cm</span>', size_unit: 'mm')

Will produce the following output:

'[size=150]text 15 cm[/size]'

Notice: When the size unit is not specified, the size value is not converted.

Supported tags

Currently, the library supports all the necessary HTML tags:

  • a (a link)
  • b
  • blockquote
  • del
  • em
  • font
  • i
  • ins
  • img
  • li
  • ol
  • pre
  • s
  • span (text formatting)
  • strong
  • table
  • td
  • tr
  • u
  • ul

Contributing to html2bbcode

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright (c) 2013 Szymon Kieloch. See LICENSE.txt for further details.