pazuzu156/kparser

用于我的网站的解析包

v1.2.8.2 2018-09-14 21:22 UTC

This package is auto-updated.

Last update: 2024-09-15 10:21:44 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

一个简单的用于我的网站的解析工具。

关于

KParser 是一个用于我的网站的解析工具。它支持 BBCode,我自己的某些变体,以及使用 GeSHi 的语法高亮支持

支持的标签

[p]Paragraph Tag[/p]  
[b]Bold Text Tag[/p]  
[i]Italicized Tag[/i]  
[u]Underlined Text Tag[/u]  
[s]Strikethrough Text Tag[/s]  
[o]Overlined Text Tag[/o]  
[hr] - Horizonal Rule Tag  
[hr type=classname] - Horizonal Rule Tag with custom class  
[ul]Unordered List[/ul]  
[ol]Ordered List[/ol]  
[li]List Item Tag - Place inside ordered or unordered list tags[/li]  
[code=language]Code Block Tag[/code] - Code block is tied in with GeSHi; the syntax highlighter for PHP. GeSHi is required to use KParser because of this  
[youtube url=YOUTUBE_VIDEO_URL] - Uses full or share link for YouTube videos  
[size=SIZE]Sized text based on SIZE[/size]
[color=COLOR]Colored text based on COLOR. Can be real value or HEX (red OR #ff0000)[/color]
[center]Centered Text[/center]
[quote]Quoted text with no source cited[/quote]
[quote=Quoted Dude]Quoted text with source cited[/quote]
[url]Unnamed URL[/url]
[url=http://example.com]Named URL[/url]
[url=http://example.com newtab]Named URL that opens in a new tab[/url]
[img src=http://example.com/images/image.jpg] Image
[img src=http://example.com/images/image.jpg class=img-class] Image with class
[img src=http://example.com/images/image.jpg size=150] Sized image defining width
[img src=http://example.com/images/image.jpg size=150x100] Sized image defining width and height
[video src=http://example.com/videos/video.mp4] HTML5 video
[video src=http://example.com/videos/video.mp4 controls] HTML5 video with controls
[video src=http://example.com/videos/video.mp4 size=500x400] HTML5 video with width and height
[video src=http://example.com/videos/video.mp4 size=500] HTML5 video with global size
[video src=http://example.com/videos/video.mp4 controls size=500] HTML5 video with global size and controls
[hNUMBER] Heading. 1-6 for NUMBER[/hNUMBER]
[space] A single space
[spaceNUMBER] A NUMBER of spaces
[tab] A single tab
[tabNUMBER] A NUMBER of tabs
[cmd] Command line command[/cmd] - Shows a command block using <pre> and <code>
[noparse] Place KScript code in here[/noparse] - Prevents KScript from being parsed inside this block 
[cmt=COMMENT] Write a comment in your code to yourself ;)  

安装

要将此包安装到 Laravel 中,请在您的 composer.json 中包含以下内容

"pazuzu156/kparser": "1.*",

如果您希望使用 KParser 的最新“前沿”版本,请使用以下内容代替官方发布版

"pazuzu156/kparser": "dev-master"

或者..直接使用 composer ;) $ composer require pazuzu156/kparser

完成此操作后,将服务提供者和外观包括到 app/config/app.php 中

Pazuzu156\KParser\Laravel\KParserServiceProvider::class

'KParser' => Pazuzu156\KParser\Laravel\KParserFacade::class

使用方法

要使用 KParser,您可以将它包含到 php 文件中,或者使用外观通过包含的服务提供者/外观将其集成到 Blade 中。

<?php
use Pazuzu156\KParser\KParser;

class MyController extends Controller
{
    public function controllerFunction($text)
    {
    	$p = new KParser;
        return $p->parse($text);
    }
}

@extends('layout.main')
@section('content')
{!! KParser::parse('[code=php]<?php echo "Hello World!"; ?>[/code]') !!}
@stop

支持

KParser 不仅支持流行的 Laravel 框架,还支持我的 MVC 框架 Scara