PHP 的可扩展/可定制/模块化轻量级标记

发布于 2025-01-07 05:17:39 字数 1047 浏览 5 评论 0原文

我正在计划用 PHP(使用 Symfony)编写一个 Web 应用程序,我想在其中使用轻量级标记语言。应用程序中有两个具有不同要求的用例:

  1. 短文本 (),用户需要能够在其中插入图标​​/符号文本和标记内联元素(,还有 ),但没有标题或列表等“块级”功能,也没有任何链接.

  2. 较长的文本 (

我遇到的问题是,我看过的所有标记库(主要是 Textile 和 Markdown,但我搜索并查看了其他一些替代方案)都有太多功能,这些功能无法在运行时(取消)激活,并且如果不修改它们的实际代码就不容易扩展,我宁愿避免这种情况,否则我必须解析和修改生成的 HTML,这也不好。

所以我的问题是:考虑到以下功能,是否有一个更可扩展/可定制/模块化的 PHP 轻量级标记库?

  1. 轻松停用某些功能,不仅是永久停用,因为用户根本不应该使用它们(例如链接或内联 HTML),而且最好在运行时停用,因为这两个用例具有不同的要求。

  2. 轻松修改生成的 HTML 以使用不同的元素。例如,让 # Headline 生成 h3 而不是 h1,因为 h1h2 > 保留。

  3. 轻松添加功能,例如:

    • 一组固定小图标/符号的简单占位符(这是我知道 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:

  1. 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.

  2. 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?

  1. 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.

  2. Easily modify the generated HTML to use different elements. For example, have # Headline generate a h3 instead of h1 because h1 and h2 are reserved.

  3. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

遮了一弯 2025-01-14 05:17:39

尝试 Texy,http://texy.info/en/

它具有非常好的可配置性和可扩展性。

Try Texy, http://texy.info/en/

It is very good configurable and extendable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文