2017 © Pedro Peláez
 

library phpygments

Syntax highlighter bridge for pygments

image

phpygments/phpygments

Syntax highlighter bridge for pygments

  • Saturday, November 4, 2017
  • by capynet
  • Repository
  • 2 Watchers
  • 8 Stars
  • 170 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PHPygments - PHP syntax highlighter based on Pygments

Server side syntax highlighter based on Pygments highlighter software., (*1)

Installation:

To use this plugin you need pygments in your server:, (*2)

sudo apt-get install python-setuptools
easy_install Pygments

That's all. Now you can download the plugin via Composer or as independent library and use it., (*3)

Usage

require "../PHPygments.php";

$code = file_get_contents("test.js");
$result = PHPygments::render($code, "js");

//Load CSS for this highlighted code
foreach ($result["styles"] as $style) {
  print '<link href="' . $style . '" media="all" rel="stylesheet" type="text/css" />';
}

//and print the code.
echo $result["code"];

Options

PHPygments::render($code, $language, $style, $linenumbers) * $code: the source code to highlight * $language: Language type. see section "Languages and filetypes supported" in this doc. * $style: Color style to use (default to "default" style). see "Color styles" un this doc. * $linenumbers: inline or table, the line numbers will be added as independent table column or as part of the line., (*4)

Examples

[javascript]
//comment line
var foo = "foo";
var bar = function(){
    var baz;
}
[/javascript]

Outputs highlighted js with default style, and no line numbers., (*5)

[javascript style="monokai" linenumbers="inline"]
//comment line
var foo = "foo";
var bar = function(){
    var baz;
}
[/javascript]

Outputs highlighted js with monokai style with line numbers (as part of the line)., (*6)

[javascript style="monokai" linenumbers="table"]
//comment line
var foo = "foo";
var bar = function(){
    var baz;
}
[/javascript]

Outputs highlighted js with monokai style with line numbers (as new column)., (*7)

Color styles

These are supported color styles:, (*8)

  • monokai
    monokai example, (*9)

  • manni
    monokai example, (*10)

  • rrt
    monokai example, (*11)

  • perldoc
    monokai example, (*12)

  • borland
    monokai example, (*13)

  • colorful
    monokai example, (*14)

  • default
    monokai example, (*15)

  • murphy
    monokai example, (*16)

  • vs
    monokai example, (*17)

  • trac
    monokai example, (*18)

  • tango
    monokai example, (*19)

  • fruity
    monokai example, (*20)

  • autumn
    monokai example, (*21)

  • bw
    monokai example, (*22)

  • emacs
    monokai example, (*23)

  • vim
    monokai example, (*24)

  • pastie
    monokai example, (*25)

  • friendly
    monokai example, (*26)

  • native
    monokai example, (*27)

Languages and filetypes supported

Pygments not only highlights languages. also highlights filetypes like .conf Nginx configuration file, Apache (filenames .htaccess, apache.conf, apache2.conf), etc., (*28)

NOTE: to use see "Usage" section, (*29)

General
  • apacheconf: (.htaccess, apache.conf, apache2.conf)
  • bash, sh, ksh: (*.sh, *.ksh, *.bash, *.ebuild, *.eclass, .bashrc, bashrc)
  • ini, cfg: (*.ini, *.cfg)
  • makefile: (.mak, Makefile, makefile, Makefile., GNUmakefile)
  • nginx: Nginx configuration file
  • yaml: (*.yaml, *.yml)
  • perl: Perl (*.pl, *.pm)
  • vb.net: VB.net (*.vb, *.bas)
  • console: Bash Session (*.sh-session)
Javascript
  • javascript: Pure Javascript
  • coffeescript: Pure CoffeeScript
  • json: Pure JSON
PHP
  • cssphp: PHP embedded in CSS
  • htmlphp: PHP embedded in HTML
  • jsphp: PHP embedded in JS
  • php: Pure PHP
  • xmlphp: PHP embedded in XML
Ruby
  • ruby, duby: Ruby (*.rb, *.rbw, *.rake, *.gemspec, *.rbx, *.duby)
  • csserb, cssruby: Ruby embedded in CSS
  • xmlerb, xmlruby: Ruby embedded in XML
CSS and CSS compilers
  • css: CSS (*.css)
  • sass: Sass (*.sass)
  • scss: SCSS (*.scss)
HTML and HTML template systems
  • html: HTML (*.html, *.htm, *.xhtml, *.xslt)
  • haml: Haml (*.haml)
  • jade: Jade (*.jade)
SQL
  • sql: SQL (*.sql)
  • sqlite3: sqlite3con (*.sqlite3-console)
  • mysql: MySQL
Python, jinja & Django
  • python: Pure Python
  • python3: Pure Python 3
  • xmldjango, xmljinja: Django/Jinja embedded in XML
  • cssdjango, cssjinja: Django/Jinja embedded in CSS
  • django, jinja: Pure Django/Jinja
  • htmldjango, htmljinja: Django/Jinja embedded in HTML
  • jsdjango, jsjinja: Django/Jinja embedded in Javascript
Java && family
  • java: Java (*.java)
  • clojure: clojure (*.clj)
  • groovy: Groovy (*.groovy)
  • jsp: Java Server Page (*.jsp)
C, C++, Objetive-c, C Sharp
  • cobjdump: c-objdump (*.c-objdump)
  • c: C (*.c, *.h, *.idc)
  • cpp: C++ (*.cpp, *.hpp, *.c++, *.h++, *.cc, *.hh, *.cxx, *.hxx)
  • csharp: C# (*.cs)
  • objectivec: (*.m)
XML
  • xml: (*.xml, *.xsl, *.rss, *.xslt, *.xsd, *.wsdl)
  • xslt: (*.xsl, *.xslt)

The Versions

04/11 2017

dev-master

9999999-dev https://github.com/capy/PHPygments

Syntax highlighter bridge for pygments

  Sources   Download

MIT

The Requires

  • php >=5.3

 

by Capy - Marcelo Tosco

syntax highlighter highlighter

17/03 2014

1.0.2

1.0.2.0 https://github.com/capy/PHPygments

Syntax highlighter bridge for pygments

  Sources   Download

MIT

The Requires

  • php >=5.3

 

by Capy - Marcelo Tosco

syntax highlighter highlighter

30/04 2013

1.0.1

1.0.1.0 https://github.com/capy/PHPygments

Syntax highlighter bridge for pygments

  Sources   Download

MIT

The Requires

  • php >=5.3

 

by Capy - Marcelo Tosco

syntax highlighter highlighter

26/04 2013

1.0.0

1.0.0.0 https://github.com/capy/PHPygments

Syntax highlighter bridge for pygments

  Sources   Download

MIT

The Requires

  • php >=5.3

 

by Capy - Marcelo Tosco

syntax highlighter highlighter