PHP 的可扩展/可定制/模块化轻量级标记
我正在计划用 PHP(使用 Symfony)编写一个 Web 应用程序,我想在其中使用轻量级标记语言。应用程序中有两个具有不同要求的用例:
短文本 (
),用户需要能够在其中插入图标/符号文本和标记内联元素(
,还有
),但没有标题或列表等“块级”功能,也没有任何链接.
较长的文本 (
我遇到的问题是,我看过的所有标记库(主要是 Textile 和 Markdown,但我搜索并查看了其他一些替代方案)都有太多功能,这些功能无法在运行时(取消)激活,并且如果不修改它们的实际代码就不容易扩展,我宁愿避免这种情况,否则我必须解析和修改生成的 HTML,这也不好。
所以我的问题是:考虑到以下功能,是否有一个更可扩展/可定制/模块化的 PHP 轻量级标记库?
轻松停用某些功能,不仅是永久停用,因为用户根本不应该使用它们(例如链接或内联 HTML),而且最好在运行时停用,因为这两个用例具有不同的要求。
轻松修改生成的 HTML 以使用不同的元素。例如,让
# Headline
生成h3
而不是h1
,因为h1
和h2
> 保留。轻松添加功能,例如:
- 一组固定小图标/符号的简单占位符(这是我知道 Markdown 提供基本支持的一件事)。
- 自定义内联元素,例如将
~Test~
转换为Text
。
Im planning a web application written in PHP (with Symfony) where I'd like to use a lightweight markup language. There will be two use cases in the app with different requirements:
Short texts (
<input type="text">
) where the user will need be able to insert icons/symbols into the text and markup inline elements (<strong>
, but also<small>
), but no "block level" features such as headlines or lists, nor any links.Longer texts (
<textarea>
) where the user mostly needs headlines, bullet point lists and again "span" elements, but also no links.
The problem I have, is that all markup libraries I've looked at (mainly Textile and Markdown, but I searched and looked at some other alternatives) have too many features, that can't be (de)activated during runtime, and are not easily extendable without modifying their actual code, which I'd prefer to avoid, or I'd have to parse and modify the generated HTML, which isn't nice either.
So my question is: Is there a more extendable/customizable/modular lightweight markup library for PHP considering following features?
Easily deactivate certain features, not only permanently because the user shouldn't be able to use them at all (e.g. Links or inline HTML), but preferringly also during runtime, because of the two use cases with different requirements.
Easily modify the generated HTML to use different elements. For example, have
# Headline
generate ah3
instead ofh1
becauseh1
andh2
are reserved.Easily add features such as:
- Simple placeholders for a fixed set of small icons/symbols (this is the one thing I know Markdown has basic support for).
- Custom inline elements, for example have
~Test~
convert to<small>Text</small>
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 Texy,http://texy.info/en/
它具有非常好的可配置性和可扩展性。
Try Texy, http://texy.info/en/
It is very good configurable and extendable.