Git Product home page Git Product logo

luminous's Introduction

Luminous - a Syntax Highlighter for PHP

Build Status

Luminous is an accurate and style-able syntax highlighter for PHP which supports a bunch of common languages and output to HTML and LaTeX.

If you simply want to use Luminous as a library, please don't clone this repository. Or if you do, make sure you delete luminous/tests afterwards. Do not expose luminous/tests on a public machine. It is recommended to get a packaged version from the links below.

##Links:

Installation

Extract your tarball, zip, whatever, into some directory where it's going to be used (i.e. probably your web-server). We'll assume it's called `luminous/'

Alternatively, Composer:

Luminous is also available via Packagist as a Composer package:

{
        "require": {
                "luminous/luminous": "0.7.*"
        }
}

Quick Usage

First, if you're going to use caching, which you probably are, create a directory called luminous/cache and give it writable permissions (chmod 777 on most servers -- yours may accept a less permissive value). Then include luminous/luminous.php and away you go!

<?php
require_once 'luminous/luminous.php';
echo luminous::head_html(); // outputs CSS includes, intended to go in <head>
echo luminous::highlight('c', 'printf("hello world\n");');

Useful examples can be found in luminous/examples/. If you have problems, check that luminous/examples/example.php works.

Autoloading, PSR-0 and stuff.

Luminous's entire public interface is in the Luminous class, and this is autoloadable, if you want.

<?php
// via SplClassLoader
$classLoader = new SplClassLoader(null, 'luminous');
$classLoader->register();
echo luminous::highlight('c', 'printf("hello world")'); // works

// alternatively, via Composer's autoload:
<?php
require 'vendor/autoload.php';
echo luminous::highlight('c', 'printf("hello world")');  // works

Command Line Usage

If you're crazy and want to use Luminous/PHP on the command line, guess what, you can!

$ cd luminous/
$ php luminous.php --help

Polite Warning

Luminous is fairly slow. But it caches! So it's not slow. Or is it?

It depends on your use-case, is the simple answer. Most people should make sure the cache works (create luminous/cache with appropriate permissions), and after that, Luminous will almost certainly have negligable impact on their performance.

Optimizations are welcome, but not at the expense of maintainability.

Caching

The cache can be stored either directly on the file system or in a MySQL table (support for other DBMSs will come later, patches welcome). In either case, check out the cache documentation.

Licensing

Luminous is distributed under the LGPL but includes a bunch of stuff which is separate.

  • Everything under src/ and languages/ is part of Luminous.
  • Everything under tests/regression// is real source code taken from various projects, which is used only as test data. It is all GPL-compatible, but is distributed under its own license. This directory is only present in the git repository and is not part of any stable distribution archives.
  • We also include jQuery which is provided under its own license.

luminous's People

Contributors

markwatkinson avatar j5lx avatar alecsammon avatar chrisboulton avatar

Watchers

James Cloos avatar Narender Rathore avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.