Download the PHP package ramsey/twig-codeblock without Composer

On this page you can find all versions of the php package ramsey/twig-codeblock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package twig-codeblock

Codeblock Extension for Twig

Add code snippets with syntax highlighting and more to any Twig template.

Source Code Latest Version Software License Build Status Coverage Status Total Downloads

The Codeblock extension for Twig is a port of the {% codeblock %} liquid tag for Octopress/Jekyll.

By default, Codeblock uses Pygments, the Python syntax highlighter, to generate HTML markup suitable for highlighting blocks of code, but it may use any syntax highlighter. To use another syntax highlighter, simply implement HighlighterInterface (see below for an example).

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Installation

The preferred method of installation is via Packagist and Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

Usage

Options

A number of options are available to Codeblock. Note that order does not matter.

Option Example Description
lang lang:"php" Tells the syntax highlighter the programming language being highlighted. Pass "plain" to disable highlighting.
title title:"Figure 2." Add a title to your code block.
link link:"https://example.com" Add a link to your code block title.
link_text link_text:"Download Code" Text to use for the link. Defaults to "link".
linenos linenos:false Use false to disable line numbering. Defaults to true.
start start:42 Start the line numbering in your code block at this value.
mark mark:4-6,12 Mark specific lines of code. This example marks lines 4, 5, 6, and 12.
class class:"myclass foo" Add CSS class names to the code <figure> element.
format format:"html" The output format for the syntax highlighter. Defaults to "html."

Example

Configuration

By default, Codeblock uses Pygments and, if pygmentize is in your PATH, then you do not need to pass any arguments.

If pygmentize is not in the PATH, you may specify its location:

Pygments

By default, Pygments is used for highlighting code. You will need to install Pygments and ensure that the pygmentize CLI tool is available on your system. See the Configuration section for help configuring Codeblock if pygmentize is not in your PATH.

pip install Pygments

Styles

A syntax highlighter, such as Pygments, requires a stylesheet for the markup it generates. Pygments provides some stylesheets for you, which you may list from the command line:

pygmentize -L styles

To output and save one of these styles for use in your application, use:

pygmentize -S solarizedlight -f html > solarizedlight.css

Additionally, there are many custom Pygments styles found on the web, and you may create your own.

Languages

If using Pygments, here are just a few of the languages (lexers) it supports:

To see more, type the following from the command line:

pygmentize -L lexers

Using your own highlighter

If you have your own highlighter class that implements Ramsey\Twig\CodeBlock\Highlighter\HighlighterInterface, then you may specify the fully-qualified classname as the first argument to the extension. The second argument is an array of 0-indexed values that will be passed as arguments to your class constructor. Make sure that you specify them in the correct order as your constructor requires.

Contributing

Contributions are welcome! Please read CONTRIBUTING for details.

Copyright and license

The ramsey/twig-codeblock library is copyright © Ben Ramsey and licensed for use under the MIT License (MIT). Please see LICENSE for more information.


All versions of twig-codeblock with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
ramsey/pygments Version ^1.0
twig/twig Version ^1.15 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ramsey/twig-codeblock contains the following files

Loading the files please wait ....