Git Product home page Git Product logo

bbgun's Introduction

rule bold
  ('[b]'/'[B]')
  (!'[/b]' !'[/B]'
  (tag <RbbCode::TagNode> / .))+
  ('[/b]' / '[/B]')
end

BBGun

Homepage

Rails Gem for BBCode. This gem is fundamentally limited because it uses regex to parse the code, which means it really screws the pooch on nested tags. If you’re alright with not having nested tags, then this gem may be for you.

Install

Add:

gem "bbgun"

to your Gemfile and then install the gem using:

bundle install

Usage

The easiest way to use tbbc is with the string method provided, for example

>> "[b]Bold[/b]".tbbc
=> "<strong>Bold</strong>"

Configuration

On the fly

If you want to quickly change something, e.g. disable a tag for a specific .tbbc call then you can configure it in the call:

>> "[b]Bold[/b] [i]Italic[/i]".tbbc(:strong_enabled => false)
=> "[b]Bold[/b] <i>Italic</i>"

Whilst this method works its not the cleanest way of doing it. Its fine for simple things like disabling a single tag (e.g. tables in signatures) but when defining custom tags or the coderay css its better to use the other config method

Globaly

This is done using config/initializers/tbbc.rb, this file needs to look like this:

BBGun.configure do |c|
    c.strong_enabled = false

end

That would produce the same output as the on the fly config but would work when ever you used .tbbc in the project.

bbgun's People

Contributors

arcath avatar petemichaud avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.