• Stars
    star
    2
  • Language
    PHP
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A copy of Golonka\BBCode after original repo got deleted (it's a dependency for Part-DB)

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

The Golonka\BBCodeParser package will help you with parsing BBCode.

Install

Via Composer

$ composer require golonka/bbcodeparser

Usage

To parse some text it's as easy as this!

$bbcode = new Golonka\BBCode\BBCodeParser;

echo $bbcode->parse('[b]Bold Text![/b]');
// <strong>Bold Text!</strong>

Would like the parser to not use all bbcodes? Just do like this.

$bbcode = new Golonka\BBCode\BBCodeParser;

echo $bbcode->only('bold', 'italic')
            ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]');
            // <strong>[u]Bold[/u] <em>Italic</em>!</strong>

echo $bbcode->except('bold')
            ->parse('[b]Bold[/b] [i]Italic[/i]');
            // [b]Bold[/b] <em>Italic</em>

By default the parser is case sensitive. But if you would like the parser to accept tags like [B]Bold Text[/B] it's really easy.

$bbcode = new Golonka\BBCode\BBCodeParser;

// Case insensitive
echo $bbcode->parse('[b]Bold[/b] [I]Italic![/I]', true);
     // <strong>Bold</strong> <em>Italic!</em>

// Or like this

echo $bbcode->parseCaseInsensitive('[b]Bold[/b] [i]Italic[/i]');
     // <strong>Bold</strong> <em>Italic!</em>

You could also make it more explicit that the parser is case sensitive by using another helper function.

    $bbcode = new Golonka\BBCode\BBCodeParser;

    echo $bbcode->parseCaseSensitive('[b]Bold[/b] [I]Italic![/I]');
         // <strong>Bold</strong> [I]Italic![/I]

If you would like to completely remove all BBCode it's just one function call away.

    $bbcode = new Golonka\BBCode\BBCodeParser;

    echo $bbcode->stripBBCodeTags('[b]Bold[/b] [i]Italic![/i]');
         // Bold Italic!

Laravel integration

The integration into Laravel is really easy, and the method is the same for both Laravel 4 and Laravel 5. Just open your app.php config file.

In there you just add this to your providers array

'Golonka\BBCode\BBCodeParserServiceProvider'

And this to your facades array

'BBCode' => 'Golonka\BBCode\Facades\BBCodeParser'

The syntax is the same as if you would use it in vanilla PHP but with the BBCode:: before the methods. Here are some examples.

// Simple parsing
echo BBCode::parse('[b]Bold Text![/b]');

// Limiting the parsers with the only method
echo BBCode::only('bold', 'italic')
        ->parse('[b][u]Bold[/u] [i]Italic[/i]![/b]');
        // <strong>[u]Bold[/u] <em>Italic</em>!</strong>

// Or the except method
echo BBCode::except('bold')
        ->parse('[b]Bold[/b] [i]Italic[/i]');
        // [b]Bold[/b] <em>Italic</em>

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

More Repositories

1

CrookedStyleSheets

Webpage tracking only using CSS (and no JS)
CSS
3,288
star
2

UE4-CheatSheet

An Cheat Sheet for Unreal Engine 4 C++ programming, licensed under CC BY-NC-SA 4.0
TeX
431
star
3

ESP32Console

Extensible UART console library for ESP32 with useful included commands.
C++
152
star
4

settings-bundle

A bundle to easily create typesafe, user-configurable settings for symfony applications
PHP
73
star
5

PCBruler

A PCB Ruler created in KiCAD
66
star
6

DS1054_BodePlotter

A Python program that plots Bode diagrams of a component using a Rigol DS1054Z and a JDS6600
Python
34
star
7

SDBatchToolsGUI

A Gui for the Substance Designer Tools
C#
24
star
8

WireDebugger

Debug AVRs with DebugWire via SerialPort
C#
21
star
9

AVR-ZIF-Programmer

An AVR Programmer based on USBasp which uses a ZIF-Socket for Programming.
KiCad Layout
10
star
10

2fa-webauthn

Webauthn Two-Factor-Authentictication Plugin for scheb 2fa
PHP
8
star
11

bs-treeview

TreeView element for browsers without any dependencies
TypeScript
7
star
12

FM1216duino

An Arduino Library to controlo FM1216-Tuner over I2C (only Soft-I2C)
C
7
star
13

FTController

A Motor controller for Fischertechnik with many cool features.
HTML
5
star
14

Source2Strings

A repository containing extracted strings from existing Source2 games
Shell
5
star
15

Recolldroid

A android app for comfortable use of Recoll-WebUI on android.
Java
4
star
16

ESP07-Breakout

The KiCAD Project files for my ESP07-Breakout
KiCad Layout
4
star
17

Part-DB-android

Part-DB Barcode Scanner for Android
Java
3
star
18

StuRa-Finanzsoftware

A little web project to submit PaymentOrders via a web formula and manage them in a backend. Developed for the student council of the University of Jena.
PHP
3
star
19

dompdf-font-loader-bundle

A symfony bundle to easily load custom fonts for dompdf (on cache warming)
PHP
2
star
20

Portal2HQMaterials

High Quality remake Materials for Portal 2
2
star
21

FRMorp

A tool for dumping firmware from SPMP8000 devices originally written by openschemes.com
C
1
star
22

WiFI-Sinus-Gen

The ESP8266 Code for my WLAN DDS Sinus Generator
Arduino
1
star
23

WiFi-Sinus-Generator-android

The Repository for the WiFi-Sinus-Generator Android App
Java
1
star