{"id":19826867,"url":"https://github.com/dedalozzo/pygmentize","last_synced_at":"2025-05-01T14:31:45.493Z","repository":{"id":56938299,"uuid":"11904673","full_name":"dedalozzo/pygmentize","owner":"dedalozzo","description":"Pygmentize is a wrapper to `pygmentize`, the command line interface provided by Pygments, a python syntax highlighter.","archived":false,"fork":false,"pushed_at":"2017-11-29T15:08:08.000Z","size":60,"stargazers_count":35,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-26T18:48:54.374Z","etag":null,"topics":["php","pygments","syntax-highlighter","wrapper"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dedalozzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-05T17:44:44.000Z","updated_at":"2025-02-04T07:23:51.000Z","dependencies_parsed_at":"2022-08-21T01:40:15.356Z","dependency_job_id":null,"html_url":"https://github.com/dedalozzo/pygmentize","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedalozzo%2Fpygmentize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedalozzo%2Fpygmentize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedalozzo%2Fpygmentize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dedalozzo%2Fpygmentize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dedalozzo","download_url":"https://codeload.github.com/dedalozzo/pygmentize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251890096,"owners_count":21660445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","pygments","syntax-highlighter","wrapper"],"created_at":"2024-11-12T11:11:51.916Z","updated_at":"2025-05-01T14:31:45.238Z","avatar_url":"https://github.com/dedalozzo.png","language":"PHP","readme":"[![Latest Stable Version](https://poser.pugx.org/3f/pygmentize/v/stable.png)](https://packagist.org/packages/3f/pygmentize)\n[![Latest Unstable Version](https://poser.pugx.org/3f/pygmentize/v/unstable.png)](https://packagist.org/packages/3f/pygmentize)\n[![Build Status](https://scrutinizer-ci.com/g/dedalozzo/pygmentize/badges/build.png?b=master)](https://scrutinizer-ci.com/g/dedalozzo/pygmentize/build-status/master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dedalozzo/pygmentize/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dedalozzo/pygmentize/?branch=master)\n[![License](https://poser.pugx.org/3f/pygmentize/license.svg)](https://packagist.org/packages/3f/pygmentize)\n[![Total Downloads](https://poser.pugx.org/3f/pygmentize/downloads.png)](https://packagist.org/packages/3f/pygmentize)\n\n\nPygmentize\n==========\nPygmentize is a wrapper to `pygmentize`, the command line interface provided by [Pygments](http://pygments.org), a\nPython syntax highlighter. Pygmentize is smart enough to raise an exception in case Pygments returns an error.\n\n\nComposer Installation\n---------------------\n\nTo install Pygmentize, you first need to install [Composer](http://getcomposer.org/), a Package Manager for\nPHP, following those few [steps](http://getcomposer.org/doc/00-intro.md#installation-nix):\n\n```sh\ncurl -s https://getcomposer.org/installer | php\n```\n\nYou can run this command to easily access composer from anywhere on your system:\n\n```sh\nsudo mv composer.phar /usr/local/bin/composer\n```\n\n\nPygmentize Installation\n-----------------------\nOnce you have installed Composer, it's easy install Pygmentize.\n\n1. Edit your `composer.json` file, adding Pygmentize to the require section:\n```sh\n{\n    \"require\": {\n        \"3f/pygmentize\": \"dev-master\"\n    },\n}\n```\n2. Run the following command in your project root dir:\n```sh\ncomposer update\n```\n\n\nUsage\n-----\nPygmentize is really easy to use, having only one static method. You just call `highlight()` like follows:\n\n```php\nPygmentize::highlight($code, $language);\n```\n\nMethods\n-------\n\n### Pygmentize::highlight()\n\n```php\npublic static function highlight(\n    $source,\n    $language,\n    $encoding = \"utf-8\",\n    $formatter = \"html\",\n    $style = \"borland\"\n)\n```\n\nFormats the provided source code using the specified formatter and style.\n\n**Parameters**\n\n* source\n\n  The source code.\n\n* language\n\n  The programming language name of the source code.\n\n* encoding\n\n  The file input and output encodings.\n\n* formatter\n\n  The output will be created using the provided formatter.\n\n* style\n\n  The style used by the formatter.\n\n**Returns**\n\nReturns the highlighted source code.\n\n**Exceptions**\n\n* RuntimeException\n\n  Cannot execute the `pygmentize` command.\n\n* RuntimeException\n\n  Cannot create the temporary file with the source code.\n\n\nDocumentation\n-------------\nThe documentation can be generated using [Doxygen](http://doxygen.org). A `Doxyfile` is provided for your convenience.\n\n\nRequirements\n------------\n- PHP 5.4.0 or above.\n- [Pygments](http://pygments.org) 1.6 or above.\n\n\nAuthors\n-------\nFilippo F. Fadda - \u003cfilippo.fadda@programmazione.it\u003e - \u003chttp://www.linkedin.com/in/filippofadda\u003e\n\n\nLicense\n-------\nPygmentize is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedalozzo%2Fpygmentize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdedalozzo%2Fpygmentize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedalozzo%2Fpygmentize/lists"}