cassarco/league-commonmark-wikilinks
Composer 安装命令:
composer require cassarco/league-commonmark-wikilinks
包简介
An extension that enables wikilinks parsing in league/commonmark.
README 文档
README
An extension for league-commonmark that lets you use Wikilinks in your markdown files. These will be converted to html as you have come to expect from other apps that support Wikilinks such as Wikipedia and Obsidian.
Installation
You can install the package via composer:
composer require cassarco/league-commonmark-wikilinks
Usage
use League\CommonMark\MarkdownConverter; use Cassarco\LeagueCommonmarkWikilinks\WikilinksExtension; $environment = new Environment(); $environment->addExtension(new CommonMarkCoreExtension()); $environment->addExtension(new WikiLinksExtension()); $markdown = "[[Hello World]]"; (new MarkdownConverter($environment))->convert($markdown); // <p><a href="hello-world" title="Hello World">Hello World</a></p>
Features
Convert Wikilinks to HTML Links
Surround text in double braces and this extension will automatically convert the Wikilink into an html link with a suitable title and text.
$markdown = '[[Hello World]]'; // <p><a href="hello-world" title="Hello World">Hello World</a></p>
Support for Looks-like Text
Looks-like text can be used to modify the title and text of the resulting a tag.
$markdown = '[[Hello World|Welcome]]'; // <p><a href="hello-world" title="Welcome">Welcome</a></p>
Support for Hash Links
You can optionally include hash links by adding a # followed by the hash link text to the end of the Wikilink.
$markdown = '[[Hello World#Top]]'; // <p><a href="hello-world#top" title="Hello World > Top">Hello World > Top</a></p>
Support for Hash Links combined with Looks-like Text
Of course, you can use looks-like text and hash links in combination.
$markdown = '[[Hello World#Top|Welcome]]'; // <p><a href="hello-world#top" title="Welcome">Welcome</a></p>
Support for Link Prefixes
A prefix configuration option can be used to prefix a string to the beginning of the href url.
$markdown = '[[Hello World#Top|Welcome]]'; (new MarkdownConverter($environment))->convert($markdown, [ 'prefix' => 'articles/', ] // <p><a href="articles/hello-world#top" title="Welcome">Welcome</a></p>
Handles Edge Cases Gracefully
I've tried to think of all the edge cases, but there will doubtless be more. Please submit a bug report if you encounter any issues and I will try to resolve them.
$markdown = '[[]]'; //<p>[[]]</p> $markdown = '[Hello World]'; // <p>[Hello World]</p> $markdown = '[[Hello World'; // <p>[[Hello World</p> $markdown = 'Hello World]]'; // <p>Hello World]]</p> $markdown = '[[Hello World]]]]'; // <p>[[Hello World]]]]</p> $markdown = '[[ Hello World]]'; // <p><a href="hello-world" title=" Hello World"> Hello World</a></p> $markdown = '[[Hello World|||Welcome]]'; // <p>[[Hello World|||Welcome]]</p>
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you find a bug that impacts the security of this package please send an email to security@cassar.co instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
cassarco/league-commonmark-wikilinks 适用场景与选型建议
cassarco/league-commonmark-wikilinks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 638 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「markdown」 「cassarco」 「wikilinks」 「league-commonmark-wikilinks」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cassarco/league-commonmark-wikilinks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cassarco/league-commonmark-wikilinks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cassarco/league-commonmark-wikilinks 相关的其它包
同方向 / 同关键字的高下载量 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
Creates a markdown changelog for your GitHub repository.
Lightweight Application To Convert WordPress Readme Into Github Markdown
The Attogram Framework provides developers a PHP skeleton starter site with a content module system, file-based URL routing, IP-protected backend, Markdown parser, jQuery and Bootstrap. Core modules available to add an integrated SQLite database with web admin, user system, and more.
Parser for Markdown.
统计信息
- 总下载量: 638
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-18