conde-nast-international / copilot-markdown-generator
此包已被 废弃 并不再维护。未建议替代包。
为 Copilot 风格的 Markdown 标签提供生成器类。
v0.2.2
2018-09-26 13:10 UTC
Requires
- php: >=5.3
Requires (Dev)
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ^2.9
This package is not auto-updated.
Last update: 2023-04-29 21:12:38 UTC
README
为 Copilot 风格的 Markdown 标签提供生成器类。
这是一个用于生成 Copilot 风格 Markdown 的工具库,专为在 PHP 实现的 Flyway 集成 API 中使用而创建。
安装
使用 Composer
$ composer require conde-nast-international/copilot-markdown-generator
基本用法
use CopilotTags\Text; $tag = new Text("Hello world!"); $markdown = $tag->render(); echo $markdown; // Hello world!
查看 示例实现,它展示了如何使用库将自定义 XML 内容转换为 Markdown。
贡献
查看 贡献 文档,了解如何向项目贡献。
API
此库是 CopilotTags
命名空间中的简单 Markdown 生成器类的集合(例如 CopilotTags\Paragraph
)。
一些生成器接受文本参数。给定的文本值可以包含任何有效的 Copilot 风格 Markdown,允许嵌套标签。
注意:您需要转义源内容中不应被视为 Markdown 的任何 Markdown 字符。
addcslashes($content, "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
CopilotTag
标签生成器类的接口。
-
CopilotTag->render()
将标签对象渲染为美观的 Copilot 风格 Markdown 字符串。
返回:字符串(Markdown)
Text
无格式文本生成器。
(new Text("Hello world!"))->render(); // "Hello world!"
new Text($text)
text: 字符串(Markdown)
Heading
ATX 标题生成器。
(new Heading("Hello world!", 3))->render(); // "\n\n### Hello world!\n"
new Heading($text[, $level])
text: 字符串(Markdown)
level: 整数(默认:2)(最小:2)(最大:4)
Paragraph
段落生成器。
(new Paragraph("Hello world!"))->render(); // "\n\nHello world!\n\n"
new Paragraph($text)
text: 字符串(Markdown)
InlineText
内联文本标签生成器:强调、加粗和删除。
(new InlineText("Hello world!", InlineTextDelimiter::EMPHASIS))->render(); // "*Hello world!*"
new InlineText($text[, $delimiter])
text: 字符串(Markdown)
delimiter: 字符串(默认:"")
内联文本分隔符
类常量 | 值 | 也称为 |
---|---|---|
强调 |
* |
斜体,em |
粗体 |
** |
加粗 |
删除 |
~~ |
删除线,strike,del |
链接
链接生成器 链接。
(new Link("Hello world!", "https://github.com/"))->render(); // "[Hello world!](https://github.com/)" (new Link("Hello world!", "https://github.com/", array("rel"=>"nofollow")))->render(); // "[Hello world!](https://github.com/){: rel=\"nofollow\" }"
new Link([$text, $href, $attributes])
text: 字符串 (Markdown) (默认:""
)
href: 字符串 (默认:""
)
attributes: 数组 (默认:[]
)
引用
引用生成器 引用。
(new Blockquote("Hello world!"))->render(); // "\n> Hello world!\n"
new Blockquote($text)
text: 字符串(Markdown)
列表标签
列表生成器 列表。
(new ListTag(["First", "Second"]))->render(); // "\n\n* First\n* Second\n\n" (new ListTag(["First", "Second"], TRUE))->render(); // "\n\n1. First\n2. Second\n\n"
new ListTag($items[, $ordered])
items: 数组 (Markdown)
ordered: 布尔型 (默认:FALSE
)
嵌入
嵌入生成器 嵌入。
(new Embed("https://github.com", EmbedSubtype::IFRAME))->render(); // "\n\n[#iframe: https://github.com]\n\n" (new Embed("https://github.com", EmbedSubtype::IFRAME, "My caption."))->render(); // "\n\n[#iframe: https://github.com]|||My caption.|||\n\n"
new Embed($uri[, $subtype, $caption])
uri: 字符串
subtype: 字符串 (默认:EmbedSubtype::IFRAME
)
caption: 字符串 (默认:""
)
嵌入子类型
有效的嵌入 子类型 的类常量。请参阅 源文件 以获取更多信息。