netcarver/textile
Composer 安装命令:
composer require netcarver/textile
包简介
Textile markup language parser
README 文档
README
Textile reference | Live editor
PHP-Textile is a modern Textile markup language parser for PHP. Textile is a humane web text generator that takes lightweight, readable, plaintext-like markup language and converts it into well formed HTML.
Install
Using Composer:
$ composer require netcarver/textile
Usage
The Textile parser can be accessed through the Netcarver\Textile\Parser class. The class is highly configurable, and actual parsing happens with the parse method:
require './vendor/autoload.php';
$parser = new \Netcarver\Textile\Parser();
echo $parser->parse('h1. Hello World!');
Parsing untrusted input
If you are using PHP-Textile to format user-supplied input, blog comments for instance, remember to enable restricted parser mode:
$parser = new \Netcarver\Textile\Parser();
echo $parser
->setRestricted(true)
->parse('!bad/image/not/allowed.svg!');
In restricted mode PHP-Textile doesn’t allow more powerful formatting options such as inline styles, and removes any raw HTML.
Parsing single-line fields
If you are using PHP-Textile as a field-level formatter to parse just inline spans and glyphs, use the setBlockTags method to disable block tags:
$parser = new \Netcarver\Textile\Parser();
echo $parser
->setBlockTags(false)
->parse('Hello *strong* world!');
The above outputs:
Hello <strong>strong</strong> world!
Doctypes
Currently, PHP-Textile can target either XHTML or HTML5 output with XHTML being the default for backward compatibility. The targeted doctype can be changed via the setDocumentType method:
$parser = new \Netcarver\Textile\Parser();
echo $parser
->setDocumentType('html5')
->parse('HTML(HyperText Markup Language)');
Setting alternate glyphs
Textile’s typographic substitutions can be overridden with the setSymbol method. If you need to setup Textile to do non-standard substitutions, call setSymbol before you parse the input with parse.
$parser = new \Netcarver\Textile\Parser();
$parser
->setSymbol('half', '1⁄2')
->parse('Hello [1/2] World!');
The symbol names you can pass to setSymbol can be found here.
Prefixing relative image and link paths
Setting prefix might be useful if you want to point relative paths to certain consistent location:
$parser = new \Netcarver\Textile\Parser();
$parser
->setImagePrefix('/user/uploads')
->setLinkPrefix('/')
->parse('!image.jpg! "link":page');
Getting in contact
The PHP-Textile project welcomes constructive input and bug reports from users. Please open an issue on the repository for a comment, feature request or bug.
Development
See CONTRIBUTING.textile.
netcarver/textile 适用场景与选型建议
netcarver/textile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.53M 次下载、GitHub Stars 达 229, 最近一次更新时间为 2012 年 08 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「parser」 「html」 「language」 「document」 「markup」 「format」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 netcarver/textile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 netcarver/textile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 netcarver/textile 相关的其它包
同方向 / 同关键字的高下载量 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
Easy to use i18n translation PHP class for multi-language websites
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Package for convenient work with Laravel's localization features
Store your language lines in the database, yaml or other sources
Set Links with a specific language parameter
统计信息
- 总下载量: 1.53M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 231
- 点击次数: 30
- 依赖项目数: 24
- 推荐数: 2
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2012-08-24