interitty/markdown
Composer 安装命令:
composer require interitty/markdown
包简介
Support for Markdown language in Nette framework and templating system Latte.
README 文档
README
Support for Markdown language in Nette framework and templating system Latte.
Requirements
Installation
The best way to install interitty/markdown is using Composer:
composer require interitty/markdown
This package has no direct dependency on one particular implementation of the Markdown parser. It allows work uniformly with different libraries using dedicated adapters. When the selected option is no longer suitable or available for the current version of PHP, select another suitable option in the configuration.
The following composer packages are currently supported. It is possible to choose and install one or more at the same time.
composer require league/commonmark
composer require michelf/php-markdown
Then register the extension in the Nette config file:
# app/config/config.neon
extensions:
markdown: Interitty\Markdown\Nette\DI\MarkdownExtension
Usage
A filter and tag can be used in any Latte template:
Inline support
HTML templates and mocks for web applications often come with a pre-formatted document to which translations
need to be added. This is done by default using the {_...} notation. Minor corrections are then made
over time in the form of text changes and highlighting. For these purposes, it is useful to provide limited
markdown language support to allow this without
the need to change the application code using the md filter or tag.
<p>{_'**Markdown** text content'|md}</p>
This function can of course also be used without the need for translations.
<p>{md '**Markdown** text content'}</p>
By default, the following HTML tags are supported in "inline" mode:
a, abbr, b, br, cite, code, command, del, dfn, em, i, ins, kbd, mark, meter, progress, q, s, samp, small, span, strong, sub, sup, time, u, var, wbr.
All others are removed from the resulting string. The list of allowed HTML tags can be changed in the allowedTagsInline configuration item.
# app/config/config.neon
markdown:
allowedTagsInline: [b, i, u]
Block support
Sometimes you need to convert the whole markdown document without any restrictions.
For this purpose, there is a "block" mode with its mdb filter and tag helper.
{block|mdb}
## Headline
**Markdown** text content
{/block}
{capture $markdownText}
## Headline
**Markdown** text content
{/capture}
{md $markdownText}
Standalone usage
Sometimes it can be useful to convert markdown text on its own without using the templating system. This can be done
using the Interitty\Markdown\Markdown object obtained from the dependency injection container.
<?php
declare(strict_types=1);
namespace App\Models;
use Interitty\Markdown\Markdown;
class FooService
{
public function __construct(
protected Markdown $markdown
) {
}
public function processMarkdown(string $markdown): string
{
return $this->markdown->processMarkdown($markdown);
}
}
Configuration
The extension is designed so that nothing more needs to be set by default. The currently installed parser is used
as a latte filter md. However, it may be useful to use it under a different identifier, with a different service, or with the support for just a strict markdown.
# app/config/config.neon
markdown:
adapter: null # Can be one of `commonMark`, `githubFlavoured`, `markdown`, `markdownExtra`, `texy` or one of `@service`
allowedTagsInline: null # Or array of strings with allowed HTML tags for "inline" filter and tag.
extended: true # false for strict markdown syntax only
helper: `mdb` # Any string like `parsedown` to be compatible with previous markdown support implementation
helperInline: `md` # Any string
Events
The markdown service also contains events that can modify the text input and output during processing. This can be useful, for example, for additional typographic editing that is not directly supported by the Markdown adapter itself.
The available events are onBeforeProcess, onAfterProcess and onAfterInlineProcess.
extensions:
markdown: Interitty\Markdown\Nette\DI\MarkdownExtension
services:
markdown.markdown:
class: Interitty\Markdown\Markdown
setup:
- $onAfterProcess:
- strtolower
interitty/markdown 适用场景与选型建议
interitty/markdown 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「markdown」 「nette」 「latte」 「md」 「interitty」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 interitty/markdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 interitty/markdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 interitty/markdown 相关的其它包
同方向 / 同关键字的高下载量 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
Nette Framework adapter for I18n package
Build forms from schema
Asynchronous MQTT client built on React
Form with datetime support and Bootstrap 4 form renderer
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-25