patrickrose/markdown-extender
Composer 安装命令:
composer require patrickrose/markdown-extender
包简介
Extend Markdown extra with ease
关键字:
README 文档
README
Do you use Markdown to write blog posts and websites? Do you really hate the fact that embedding things like YouTube videos is a bit of a pain and you want it to be a bit more...Markdown-y? Meet Markdown Extender.
This extends the michelf/php-markdown package to provide new functionality and also allow you to extend.
Installation
Add the following to your composer.json.
"require": { "patrickrose/markdown-extender": "~1" }
Usage
Build up your markdown string and pass it to the compile function. Extensions are
handled using the syntax [{extensionName:arg1,arg2,arg3}] in your markdown.
If you need a new function then you can add it using
extend($extensionName, $extensionFunction), where $extensionName is the string to use
inside the [{}] block and $extensionFunction is a closure that takes any number of
arguments and returns a string.
Current Functions
- Youtube Embedding:
[{youtube:youtubeID}]=><iframe width="560" height="315" src="//www.youtube.com/embed/BgAdeuxkUyY" frameborder="0" allowfullscreen></iframe> - Vimeo Embedding:
[{vimeo:vimeoID}]=><iframe src="//player.vimeo.com/video/95810934" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> - Tweet Embedding:
[{twitter:tweetID}]=><blockquote class="twitter-tweet"><p>Search API will now always return "real" Twitter user IDs. The with_twitter_user_id parameter is no longer necessary. An era has ended. ^TS</p>— Twitter API (@twitterapi) <a href="https://twitter.com/twitterapi/statuses/133640144317198338">November 7, 2011</a></blockquote>\n<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> - Description Lists:
[{description:item1|description1,item2|description2}]=><dl><dt>first</dt><dd>first text</dd><dt>second</dt><dd>second text</dd></dl>
Example
$markdown = new PatrickRose\MarkdownExtender\MarkdownExtender; $string = "I really like this youtube video! [{youtube:BgAdeuxkUyY}] And I added an extension: [{extended:one,two,3}]"; $markdown->extend("extended", function($one,$two,$three) { return "You passed in <em>$one</em>, <em>$two</em> and <em>$three</em>."; }); $markdown->compile($string) /* returns: "<p>I really like this youtube video!</p> <p><iframe width=\"560\" height=\"315\" src=\"//www.youtube.com/embed/BgAdeuxkUyY\" frameborder=\"0\" allowfullscreen></iframe></p> <p>And I added an extension:</p> <p>You passed in <em>one</em>, <em>two</em> and <em>3</em>.</p>" */
Laravel Users
Using Laravel? Then feel free to use the service provider and facade. First, add this to your providers array:
"providers" => [ ... "PatrickRose\\MarkdownExtender\\MarkdownExtenderServiceProvider", ]
And add the facade to your aliases array
"aliases" => [ ... "MarkdownExtender" => "PatrickRose\\MarkdownExtender\\Facades\\MarkdownExtender" ]
Then you can use MarkdownExtender::compile($markdown) and
MarkdownExtender::extend($extension).
patrickrose/markdown-extender 适用场景与选型建议
patrickrose/markdown-extender 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「markdown」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 patrickrose/markdown-extender 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 patrickrose/markdown-extender 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 patrickrose/markdown-extender 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Adds more BBCode
Creates a markdown changelog for your GitHub repository.
Lightweight Application To Convert WordPress Readme Into Github Markdown
The Attogram Framework provides developers a PHP skeleton starter site with a content module system, file-based URL routing, IP-protected backend, Markdown parser, jQuery and Bootstrap. Core modules available to add an integrated SQLite database with web admin, user system, and more.
Parser for Markdown.
统计信息
- 总下载量: 33
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-26