pagerange/metaparsedown
Composer 安装命令:
composer require pagerange/metaparsedown
包简介
Adds ability to have meta data in markdown files parsed by eursev/parsedown or eruseve/parsedown-extra
README 文档
README
MetaParsedown extends erusev/parsedown and eruseve/parsedown-extra, very nice markdown parsers, by adding the ability to have metadata in markdown or markdown-extra files in the form of valid yaml. MetaParsedown uses the Symfony Yaml component to parse and extract the metadata. I created this because we were creating a markdown document management system and needed a way to add metadata to each file. The other option was a separate metadata file for each markdown file, which is fine, but seemed cumborsome for those creating the documents. This way seemed easier and is pretty simple to use.
MetaParsedown retains all the functionality of erusev/parsedown, but adds two methods:
-
meta($markdown) -- returns an array of the key/value metadata tags in the markdown
-
stripMeta($markdown) returns bare markdown with yaml frontmatter stripped out
Parsedown's original text($markdown) method continues to return HTML, without the metadata tags
MetaParsedown is also available as a Wordpress plugin.
Installation
Please use the composer package to include Metaparsedown in your project.
composer require pagerange/metaparsedown
Adding meta data
Add metadata as valid yaml key/value pairs, delimited by three dashes at the start and end. This yaml block must appear at the start of the document.
--- title: 'My Great Document' author: 'Yours Truly' description: 'A short document with very little to say' status: 'public' created_at: '2017-11-18 12:01:00' --- # My Great Document This is the rest of the markdown document * bullet list item * bullet list item
Usage
use Pagerange\Markdown\MetaParsedown; $mp = new MetaParsedown(); echo $mp->text($markdown); // prints HTML, without meta data $meta = $mp->meta($markdown); // returns an array of key/value pairs $bare_markdown = $mp->stripMeta($markdown); // returns markdown without yaml block
See the erusev/parsedown git page or the erusev/parsedown-extra git pagefor more information and detailed documentation on how to use it and how it works.
License
MIT License
Copyright (c) 2017 Steve George
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pagerange/metaparsedown 适用场景与选型建议
pagerange/metaparsedown 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38.2k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2017 年 10 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yaml」 「markdown」 「meta」 「parsedown」 「markdown-extra」 「parsedown-extra」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pagerange/metaparsedown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pagerange/metaparsedown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pagerange/metaparsedown 相关的其它包
同方向 / 同关键字的高下载量 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
Harvest statistics and meta data from an URL or his source code (seo oriented).
Phalcon PHP Meta tags service
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Help to manage meta data on Laravel Eloquent model
A simple, repeatable field type
统计信息
- 总下载量: 38.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 27
- 点击次数: 4
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-29