HighlightBundle
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:A bundle for symfony2. The purpose is highlighting source code in template with a choiced highlighter (pygment, geshi, highlight...)
Presentation
============
This bundle transforms a part of text representing a source code in html formated text. It provides 5 highlighters :

- pygment
- geshi
- highlight
- http request to appspot
- http request to hiliteme

Two caches mechanisms permit to conserve highlighted informations about languages and work made by the highlighter, moreover symfony integrated cache.

Installation
============
###Standard symfony installation :

Add the following line in composer.json:

```json
{
//...
   "require":{
      //....
      "nicodmf/highlight-bundle": "2.1.*"
      //...
   }
}
```
Activate changes via the command:

```
php composer.phar update
```

###Manual installation

Download and decompress the bundle package in `vendor/bundles/Highlight` manually or via github:

```
git submodule add git://github.com/nicodmf/HighlightBundle.git vendor/bundles/Highlight`
```
    
- add namespace in the autoloader :

``` php
registerNamespaces(array(
    //...
    'Highlight'        => __DIR__.'/../vendor/bundles',
    //...
));
```

Activation
==========

``` php                                                                                         
    
{% endstylesheets %}
```

Options
-------
The default options can be overriden by adding options after importation of the bundle config.
An example in app/config/config.yml:

``` yaml
highlight:
   # Each provider in this list are use on after other
   # if language given in template ins't allowed
   providers: [ geshi, httphiliteme, httpappspot, highlight, pygment ]
   # All globals options can be rewrite in a specific provider
   # except cssclass who just added
   globals:
       linenos: true
       blockstyles: ""
       cssclass: highlight

   highlight:
       linenos: true
       blockstyles: ""
       cssclass: highlight

   pygment:
       linenos: true
       blockstyles: ""
       cssclass: pygment

   geshi:
       linenos: false
       # Two possibilities fancy or normal
       linestyle: normal
       cssclass: geshi

   #line number not available with appspot
   httpappspot:
       blockstyles: "overflow:auto;color:white !important;"
       cssclass: pygment appspot

   httphiliteme:
       linenos: false
       #One of : colorful default emacs friendly fruity manni monokai murphy native pastie perldoc tango trac vs
       style: pastie
       #Additionnal css directive for div block
       blockstyles: "overflow:auto;color:white !important;"
       cssclass: pygment hiliteme
       
services:
    highlight.configuration:
        class: Highlight\Bundle\HighlightBundle
        tags:
            - { name: configuration }
    highlight.twig.extension:
        class: Highlight\Bundle\Extension\TwigExtension
        tags:
            - { name: twig.extension }
        arguments: [@translator, @kernel, @service_container ]
        #arguments: [@translator, @templating.globals, @templating.helper.assets ]
```

In Twig
-------
Highlight can be used as filter, function or parser

### Filter
As a filter, highlight take a defined string or a defined string variable, the highlighter to use is optional :

```
{{ aDefinedStringVariable|highlight 'php' ['pygment'] }}
```

### Funtion
The function work with same purpose, with another syntax :

```
{{ highlight( aDefinedStringVariable, 'php'[, 'pygment']) }}
```

### Block parser
The parser is simply to use, because you don't have obligation to defined a variable. The code wich would be transformate is beetween standard twig tag. The highlighter is always optional :

```
{% highlight 'php' ['pygment'] %}

{% endhighlight %}
```

Extends
=======
Provider
--------
It is very simple to add another provider if you want to use one not listed here.

In the provider directory :

 - Create a provider class in providers
 - Add its creation in factory.php
In the DependancyInjection directory
 - Update the Configuration.php to added the new parameters


本源码包内暂不包含可直接显示的源代码文件,请下载源码包。