{"id":16557612,"url":"https://github.com/mpratt/luthor","last_synced_at":"2025-03-04T23:40:39.350Z","repository":{"id":11849274,"uuid":"14406877","full_name":"mpratt/Luthor","owner":"mpratt","description":"An extendable Markdown Lexer/Parser for PHP","archived":false,"fork":false,"pushed_at":"2013-12-12T17:09:54.000Z","size":256,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-15T08:58:20.680Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mpratt.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-11-14T21:00:47.000Z","updated_at":"2019-06-27T13:20:57.000Z","dependencies_parsed_at":"2022-07-26T08:02:09.631Z","dependency_job_id":null,"html_url":"https://github.com/mpratt/Luthor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FLuthor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FLuthor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FLuthor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpratt%2FLuthor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpratt","download_url":"https://codeload.github.com/mpratt/Luthor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940529,"owners_count":20045878,"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":[],"created_at":"2024-10-11T20:07:59.061Z","updated_at":"2025-03-04T23:40:39.331Z","avatar_url":"https://github.com/mpratt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Luthor\n======\n[![Build Status](https://secure.travis-ci.org/mpratt/Luthor.png?branch=master)](http://travis-ci.org/mpratt/Luthor)\n[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/mpratt/Luthor/badges/quality-score.png?s=24c42108df50eba8149dfc291f549dfe0d317ef1)](https://scrutinizer-ci.com/g/mpratt/Luthor/)\n[![Code Coverage](https://scrutinizer-ci.com/g/mpratt/Luthor/badges/coverage.png?s=537bc5b18469395beb0f944222c0b15bc72c9510)](https://scrutinizer-ci.com/g/mpratt/Luthor/)\n[![Latest Stable Version](https://poser.pugx.org/mpratt/luthor/v/stable.png)](https://packagist.org/packages/mpratt/luthor)\n[![Total Downloads](https://poser.pugx.org/mpratt/luthor/downloads.png)](https://packagist.org/packages/mpratt/luthor)\n\n** Warning: This library is not production ready **\n\nLuthor is an extendable Markdown Lexer/Parser for PHP. It converts markdown text into HTML. In other words, what it does is,\nIt reads the markdown text line by line and analyses its content. It uses a Lexer to tokenize each element and passes them to the parser.\nThe Parser operates on that token and returns an HTML string.\n\nThe key feature of this library, is that you can extend the token map quite easily, giving you the hability to practically have\ncustom notations and build your own flavored markdown. There are other cool things that can be easily done, like applying filters\nor modifying the way a token is handled or displayed. It also has a bunch of configuration options which can be used to change the behaviour of the library!\nSee the Usage section for more information about how everything is done. Or better yet, hop into the source and take a peak.\n\nHere is a quick list of supported markup:\n- Paragraphs and line breaks\n- Headers\n- Blockquotes\n- Code blocks and Fenced code blocks\n- Lists (starting with `* `, `- `, `+ `, or `1. `)\n- Horizontal Rules\n- Span Elements (links, emphasis, code, images, striked out text)\n- Element Escaping\n- Footnotes and Abbreviations\n- Special attributes on headers, links and images via `{#id .class1 .class2}`\n\nThe library works but is **not** stable enough to be used on production environments. In comparision with other markdown parsers, this one is\nslow! Very slow! And It takes indentation very seriously, maybe a little too much.\n\nIm not giving support for this library, this was just a hobby project. Some parts of the library could be done more elegantly and perhaps\nlater I will cleanup the codebase, but Im not making any promises.\n\nI think the best alternative, if you are looking for an extandable markdown parser is [Ciconia](https://github.com/kzykhys/Ciconia)! Elegant\nand stable, requires PHP 5.4.\n\nRequirements\n============\n- PHP \u003e= 5.3\n\nInstallation\n============\n\n### Install with Composer\nIf you're using [Composer](https://github.com/composer/composer) to manage\ndependencies, you can use this library by creating a composer.json and adding this:\n\n    {\n        \"require\": {\n            \"mpratt/luthor\": \"dev-master\"\n        }\n    }\n\nSave it and run `composer.phar install`\n\n### Standalone Installation (without Composer)\nDownload the latest release or clone this repository, place the `Lib/Luthor` directory on your project. Afterwards, you only need to include\nthe Autoload.php file.\n\n```php\n    require '/path/to/Luthor/Autoload.php';\n    $embera = new \\Luthor\\Luthor();\n```\n\nOr if you already have PSR-0 complaint autoloader, you just need to register Luthor\n```php\n    $loader-\u003eregisterNamespace('Luthor', 'path/to/Luthor');\n```\n\nBasic Usage\n===========\n\n```php\n    $lex = new \\Luthor\\Luthor();\n    echo $lex-\u003eparse('**I dont like Superman**');\n    // \u003cp\u003e\u003cstrong\u003eI dont like Superman\u003c/strong\u003e\u003c/p\u003e\n```\n\nIn order to extend the lexer/parser you need to create a new class extending the InlineAdapter or BlockAdapter.\nUse the `addExtension()` method to register the extension\n```php\n\n    class MyExtension extends \\Luthor\\Parser\\Extensions\\Adapters\\InlineAdapter\n    {\n        protected $regex = '~\\^([^ ]+)~A';\n        public function parse()\n        {\n            return '\u003cstrong\u003e' . $this-\u003ematches['1'] . '\u003c/strong\u003e';\n        }\n    }\n\n    $lex = new \\Luthor\\Luthor();\n    $lex-\u003eaddExtension(new MyExtension());\n    echo $lex-\u003eparse('I love ^Luthor !');\n    // \u003cp\u003eI love \u003cstrong\u003eLuthor\u003c/strong\u003e!\u003c/p\u003e\n```\n\nFilters are runned when the text is already processed\n```php\n    $lex = new \\Luthor\\Luthor();\n    $lex-\u003eaddFilter(function ($text){\n        return str_replace('Hello', 'World', $text);\n    });\n\n    echo $lex-\u003eparse('Hello World!');\n    // \u003cp\u003eWorld World!\u003c/p\u003e\n```\n\nTake a look at the Lib or Tests directory in order to see other configuration options.\n\nLicense\n=======\n**MIT**\nFor the full copyright and license information, please view the LICENSE file.\n\nWhy Oh' Why?\n===========\nYeah, I know right?, _another_ markdown parser? really? - You know, there are days where you think to yourself, stuff like\n\"hey, I wanna learn more about _X_, so Im going to write _Y_ and see what happens\"?, Well that happened to me a long time ago,\nand started coding this lexer/parser just for fun/learning. The thing is, I never finished it.\n\nSo one day I was digging around my \"un-finished projects\" folder and found about half of this code base and decided it was time\nto either finish it or delete it. I end up rewriting most of the code, there are bits here and there that could be done with more\nthough in mind, but in the end I think it turned out not that bad.\n\nAuthor\n=====\nHi! I'm Michael Pratt and I'm from Colombia!\n\nMy [Personal Website](http://www.michael-pratt.com) is in spanish.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpratt%2Fluthor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpratt%2Fluthor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpratt%2Fluthor/lists"}