derokorian/bbcode

简单的BBCode解析器

v1.0.2 2016-03-03 04:54 UTC

This package is auto-updated.

Last update: 2024-09-07 05:16:24 UTC


README

Build Status Code Climate Test Coverage

简单的BBCodes解析类

通过composer安装

composer require derokorian/bbcodes

使用该类

use Dero\BBCodes\BBCodes;

echo (new BBCodes)->fullClean($string);

// alternately, call clean and provide the options to use
echo (new BBCodes)->clean($string, BBCodes::OPT_LIST | BBCodes::OPT_BASIC);

// The following options exist
BBCodes::OPT_URLS
BBCodes::OPT_BASE (pre, strike, b, i, u)
BBCodes::OPT_CODE
BBCodes::OPT_LIST
BBCodes::OPT_QUOTE

BBCodes::OPT_BASIC = OPT_URLS | OPT_BASE | OPT_CODE | OPT_LIST | OPT_QUOTE

BBCodes::OPT_TITLE
BBCodes::OPT_IMG
BBCodes::OPT_NOPARSE

BBCodes::OPT_FULL = OPT_BASIC | OPT_TITLE | OPT_IMG | OPT_NOPARSE

标签

以下标签根据使用的选项提供。标签不区分大小写。

[b]bold[/b]
[i]italic[/i]
[u]underline[/u]
[strike]struck through text[/strike]

[title]some title text[/title]
[subtitle]a smallter title text[/subtitle]

[list]
    [item]list item[/item]
    [item]list item[/item]
[/list]

[url]http://example.com[/url]
[url=http://example.com]some text[/url]
[urls]block of text containing many raw urls[/urls]

[img]http://url.to/image.jpg[/img] 
[img=http://url.to/image.jpg]alt/title[/img] 

[noparse]text not to be parsed for other BBCodes[/noparse]
[quote]something attributed to someone else[/quote] 
[quote=author]something attributed to someone else[/quote] 

[pre]preformatted text[/pre]
[code]some code that needs formatting maintained[/code]

代码标签升级

默认情况下,代码标签仅保留格式,但如果您需要建议的GenSynth包,则代码可以修改为指定语言。

composer require derokorian/gen-synth

[code=language]code to be highlighted as the specific language[/code]