{"id":21556982,"url":"https://github.com/kaoken/markdown-it-php","last_synced_at":"2025-10-10T10:34:38.634Z","repository":{"id":57004373,"uuid":"77217489","full_name":"kaoken/markdown-it-php","owner":"kaoken","description":"php version markdown-it","archived":false,"fork":false,"pushed_at":"2024-03-23T05:36:21.000Z","size":651,"stargazers_count":30,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-29T23:33:20.239Z","etag":null,"topics":["commonmark","markdown","markdown-it","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"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/kaoken.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-23T10:14:45.000Z","updated_at":"2025-02-13T15:56:29.000Z","dependencies_parsed_at":"2024-03-23T06:30:14.259Z","dependency_job_id":null,"html_url":"https://github.com/kaoken/markdown-it-php","commit_stats":{"total_commits":42,"total_committers":4,"mean_commits":10.5,"dds":0.2142857142857143,"last_synced_commit":"60fb29258f9c866311590ecac58b299d8db8a872"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/kaoken/markdown-it-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaoken%2Fmarkdown-it-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaoken%2Fmarkdown-it-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaoken%2Fmarkdown-it-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaoken%2Fmarkdown-it-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaoken","download_url":"https://codeload.github.com/kaoken/markdown-it-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaoken%2Fmarkdown-it-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003544,"owners_count":26083595,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["commonmark","markdown","markdown-it","php"],"created_at":"2024-11-24T08:10:34.810Z","updated_at":"2025-10-10T10:34:38.600Z","avatar_url":"https://github.com/kaoken.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-it-php\n\n[![Build Status](https://img.shields.io/badge/build-passing-brightgreen)](https://github.com/kaoken/markdown-it-php)\n[![composer version](https://img.shields.io/badge/version-14.1.0.0-blue.svg)](https://github.com/kaoken/markdown-it-php)\n[![licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://github.com/kaoken/markdown-it-php)\n[![php version](https://img.shields.io/badge/php%20version-≧7.4.0-red.svg)](https://github.com/kaoken/markdown-it-php)\n\n\nThis gem is a port of the [markdown-it Javascript package](https://github.com/markdown-it/markdown-it) by Vitaly Puzrin and Alex Kocharin. Currently synced with markdown-it 14.1.0\n\n__[Javascript Live demo](https://markdown-it.github.io)__\n\n- Follows the __[CommonMark spec](http://spec.commonmark.org/)__ + adds syntax extensions \u0026 sugar (URL autolinking, typographer).\n- Configurable syntax! You can add new rules and even replace existing ones.\n- [Safe](https://github.com/markdown-it/markdown-it/tree/master/docs/security.md) by default.\n\n\n__Table of content__\n\n- [Install](#install)\n- [Syntax extensions](#syntax-extensions)\n- [References / Thanks](#references--thanks)\n- [License](#license)\n\n## Install\n\n**composer**:\n\n```bash\ncomposer require kaoken/markdown-it-php\n```\n\n\n### Simple\n\n```php\n$md = new MarkdownIt();\n$result = $md-\u003erender('# markdown-it rulezz!');\n```\n\nSingle line rendering, without paragraph wrap:\n\n```php\n$md = new MarkdownIt();\n$result = $md-\u003erenderInline('__markdown-it__ rulezz!');\n```\n\n\n### Init with presets and options\n\n(*) presets define combinations of active rules and options. Can be\n`\"commonmark\"`, `\"zero\"` or `\"default\"` (if skipped).\n\n```php\n// commonmark mode\n$md = new MarkdownIt('commonmark');\n\n// default mode\n$md = new MarkdownIt();\n\n// enable everything\n$md = new MarkdownIt([\n  \"html\"=\u003e        true,\n  \"linkify\"=\u003e     true,\n  \"typographer\"=\u003e true\n]);\n\n// full options list (defaults)\n$md = new MarkdownIt([\n  \"html\"=\u003e         false,        // Enable HTML tags in source\n  \"xhtmlOut\"=\u003e     false,        // Use '/' to close single tags (\u003cbr /\u003e).\n                                 // This is only for full CommonMark compatibility.\n  \"breaks\"=\u003e       false,        // Convert '\\n' in paragraphs into \u003cbr\u003e\n  \"langPrefix\"=\u003e   'language-',  // CSS language prefix for fenced blocks. Can be\n                                 // useful for external highlighters.\n  \"linkify\"=\u003e      false,        // Autoconvert URL-like text to links\n\n  // Enable some language-neutral replacement + quotes beautification\n  // For the full list of replacements, see https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js\n  \"typographer\"=\u003e  false,\n\n  // Double + single quotes replacement pairs, when typographer enabled,\n  // and smartquotes on. Could be either a String or an Array.\n  //\n  // For example, you can use '«»„“' for Russian, '„“‚‘' for German,\n  // and ['«\\xA0', '\\xA0»', '‹\\xA0', '\\xA0›'] for French (including nbsp).\n  \"quotes\"=\u003e '“”‘’',\n\n  // Highlighter function. Should return escaped HTML,\n  // or '' if the source string is not changed and should be escaped externaly.\n  // If $result starts with \u003cpre... internal wrapper is skipped.\n  \"highlight\"=\u003e function (/*str, lang*/) { return ''; }\n]);\n```\n\n### Plugins load\n\n```php\n$md = new MarkdownIt()\n            -\u003eplugin(plugin1)\n            -\u003eplugin(plugin2, opts, ...)\n            -\u003eplugin(plugin3);\n```\n\n\n### Syntax highlighting\n\nApply syntax highlighting to fenced code blocks with the `highlight` option:  \n**The sample here is only the highlight of the PHP language.**\n```php\n\n// Actual default values\n$md = new MarkdownIt([\n  \"highlight\"=\u003e function ($str, $lang) {\n    if ( $lang ) {\n      try {\n        return highlight_string($str);\n      } catch (Exception $e) {}\n    }\n\n    return ''; // use external default escaping\n  }\n]);\n```\n\nOr with full wrapper override (if you need assign class to `\u003cpre\u003e`):\n\n```php\n// Actual default values\n$md = new MarkdownIt([\n  \"highlight\"=\u003e function ($str, $lang) {\n    if ( $lang ) {\n      try {\n        return '\u003cpre\u003e\u003ccode class=\"hljs\"\u003e' .\n               highlight_string($str) .\n               '\u003c/code\u003e\u003c/pre\u003e';\n      } catch (Exception $e) {}\n    }\n\n    return '\u003cpre\u003e\u003ccode class=\"hljs\"\u003e' . $md-\u003eutils-\u003eescapeHtml($str) . '\u003c/code\u003e\u003c/pre\u003e';\n  }\n]);\n```\n\n### Linkify\n\n`linkify: true` uses [linkify-it](https://github.com/markdown-it/linkify-it). To\nconfigure linkify-it, access the linkify instance through `$md-\u003elinkify`:\n\n```php\n$md-\u003elinkify-\u003eset(['fuzzyEmail'=\u003efalse]);  // disables .py as top level domain\n```\n\n\n## Syntax extensions\n\nEmbedded (enabled by default):\n\n- [Tables](https://help.github.com/articles/organizing-information-with-tables/) (GFM)\n- [Strikethrough](https://help.github.com/articles/basic-writing-and-formatting-syntax/#styling-text) (GFM)\n\nThe following plugins are in the **kaoken\\markdown-it-php\\MarkdownIt\\Plugins** directory:\n\n- [subscript](https://github.com/markdown-it/markdown-it-sub) ``\\MarkdownItSub``\n- [superscript](https://github.com/markdown-it/markdown-it-sup) ``\\MarkdownItSup``\n- [footnote](https://github.com/markdown-it/markdown-it-footnote) ``\\MarkdownItFootnote``\n- [definition list](https://github.com/markdown-it/markdown-it-deflist) ``\\MarkdownItDeflist``\n- [abbreviation](https://github.com/markdown-it/markdown-it-abbr) ``\\MarkdownItAbbr``\n- [emoji](https://github.com/markdown-it/markdown-it-emoji) ``\\MarkdownItEmoji``\n- [custom container](https://github.com/markdown-it/markdown-it-container) ``\\MarkdownItContainer``\n- [insert](https://github.com/markdown-it/markdown-it-ins) ``\\MarkdownItIns``\n- [mark](https://github.com/markdown-it/markdown-it-mark) ``\\MarkdownItMark``\n\n\n\n### Manage rules\n\nBy default all rules are enabled, but can be restricted by options. On plugin\nload all its rules are enabled automatically.\n\n```php\n// Activate/deactivate rules, with currying\n$md = (new MarkdownIt())\n            -\u003edisable([ 'link', 'image' ])\n            -\u003eenable([ 'link' ])\n            -\u003eenable('image');\n\n// Enable everything\n$md = new MarkdownIt([\n  \"html\"        =\u003e true,\n  \"linkify\"     =\u003e true,\n  \"typographer\" =\u003e true,\n]);\n```\nYou can find all rules in sources:\n[ParserCore](src/MarkdownIt/ParserCore.php), [ParserBlock](src/MarkdownIt/ParserBlock.php),\n[ParserInline](src/MarkdownIt/ParserInline.php).\n\n## References / Thanks\n\nThanks to the authors of the original implementation in Javascript, [markdown-it](https://github.com/markdown-it/markdown-it):\n\n- Alex Kocharin [github/rlidwka](https://github.com/rlidwka)\n- Vitaly Puzrin [github/puzrin](https://github.com/puzrin)\n\nand to [John MacFarlane](https://github.com/jgm) for his work on the\nCommonMark spec and reference implementations.\n\n**Related Links:**\n\n- https://github.com/jgm/CommonMark - reference CommonMark implementations in C \u0026 JS,\n  also contains latest spec \u0026 online demo.\n- http://talk.commonmark.org - CommonMark forum, good place to collaborate\n  developers' efforts.\n  \n## License\n\n[MIT](https://github.com/markdown-it/markdown-it/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaoken%2Fmarkdown-it-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaoken%2Fmarkdown-it-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaoken%2Fmarkdown-it-php/lists"}