teppokoivula/textformatter-code-blocks
Composer 安装命令:
composer require teppokoivula/textformatter-code-blocks
包简介
ProcessWire CMS/CMF Textformatter module for creating Markdown style code blocks.
README 文档
README
ProcessWire Textformatter module for enabling Markdown style code blocks for text or RTE fields.
Note: this is not a complete Markdown implementation, but rather a home-baked implementation of just one small part of the Markdown syntax. For full Markdown support, check out the TextformatterMarkdownExtra module, bundled with ProcessWire releases by default.
Getting started
- Copy (or clone) the TextformatterCodeBlocks directory to /site/modules/
- Go to Admin > Modules, hit "Refresh", and install TextformatterCodeBlocks
- Enable "Code Blocks Textformatter" for fields in which you wish to use code blocks
IMPORTANT: if you use Code Blocks Textformatter with a regular text or textarea field, make sure that you enable HTML Entity Encoder or use another method of escaping entities!
Code blocks
Code blocks should work fine when wrapped in <p> or <pre> tags, so you can use them with RTE, such as CKEditor. This module supports two types of code blocks: fenced and inline.
Note: following code examples have been escaped for better readability when rendered in GitHub. In a nutshell the syntax for fenced code blocks is three backticks around a code block, and for inline code blocks just sourround a specific piece of code with single backticks.
Fenced code blocks
Simple example:
```
<?php
echo "This is a fenced code block.";
```
With fenced code blocks you can also specify the language for a syntax highlighter:
```php
<?php
echo "This PHP code is easier for a syntax highlighter to identify.";
```
The end result of fenced code blocks looks like this:
<pre class="code-block code-block--fenced"><code class="language-php"><?php echo "This PHP code is easier for a syntax highlighter to identify.";</code></pre>
Inline code blocks
<p>While fenced code blocks are great for longer code snippets, sometimes `<?php echo "inline code blocks"; ?>` make more sense.</p>
The end result of inline code blocks looks like this:
<p>While fenced code blocks are great for longer code snippets, sometimes <code class="code-block code-block--inline"><?php echo "inline code blocks"; ?></code> make more sense.</p>
Enabling syntax highlighter
Though syntax highlighting is not necessary for this module to work, it can be really helpful for your end users. You can use any syntax highlighter, but I would recommend Prism.js.
For detailed instructions on enabling Prism.js on your site, please visit http://prismjs.com/.
teppokoivula/textformatter-code-blocks 适用场景与选型建议
teppokoivula/textformatter-code-blocks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「module」 「markdown」 「processwire」 「textformatter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 teppokoivula/textformatter-code-blocks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 teppokoivula/textformatter-code-blocks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 teppokoivula/textformatter-code-blocks 相关的其它包
同方向 / 同关键字的高下载量 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
Installs processwire 3rd party modules to PW system "site/modules" directory.
Provides ProcessWire integration for various template engines such as Twig.
Adds more BBCode
ProcessWire module adding Smarty to the TemplateEngineFactory
Module for ProcessWire which automatically generates Blurhashs.
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-only
- 更新时间: 2019-07-07