在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kzykhys/Ciconia开源软件地址(OpenSource Url):https://github.com/kzykhys/Ciconia开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Ciconia - A New Markdown Parser for PHPThe Markdown parser for PHP5.4, it is fully extensible. Ciconia is the collection of extension, so you can replace, add or remove each parsing mechanism. Try Demo / Docs / Supported Syntax / API Reference
Requirements
Installationcreate a {
"require": {
"kzykhys/ciconia": "~1.0.0"
}
} and run
UsageTraditional Markdownuse Ciconia\Ciconia;
$ciconia = new Ciconia();
$html = $ciconia->render('Markdown is **awesome**');
// <p>Markdown is <em>awesome</em></p> Github Flavored MarkdownTo activate 6 gfm features: use Ciconia\Ciconia;
use Ciconia\Extension\Gfm;
$ciconia = new Ciconia();
$ciconia->addExtension(new Gfm\FencedCodeBlockExtension());
$ciconia->addExtension(new Gfm\TaskListExtension());
$ciconia->addExtension(new Gfm\InlineStyleExtension());
$ciconia->addExtension(new Gfm\WhiteSpaceExtension());
$ciconia->addExtension(new Gfm\TableExtension());
$ciconia->addExtension(new Gfm\UrlAutoLinkExtension());
$html = $ciconia->render('Markdown is **awesome**');
// <p>Markdown is <em>awesome</em></p> Options
use Ciconia\Ciconia;
$ciconia = new Ciconia();
$html = $ciconia->render(
'Markdown is **awesome**',
['tabWidth' => 8, 'nestedTagLevel' => 5, 'strict' => true]
); Rendering HTML or XHTMLCiconia renders HTML by default. If you prefer XHTML: use Ciconia\Ciconia;
use Ciconia\Renderer\XhtmlRenderer;
$ciconia = new Ciconia(new XhtmlRenderer());
$html = $ciconia->render('Markdown is **awesome**');
// <p>Markdown is <em>awesome</em></p> Extend CiconiaHow to ExtendCreating extension is easy, just implement Your class must implement 2 methods.
void register( |
Event | Description |
---|---|
initialize | Document level parsing. Called at the first of the sequence. |
block | Block level parsing. Called after initialize |
inline | Inline level parsing. Generally called by block level parsers. |
detab | Convert tabs to spaces. Generally called by block level parsers. |
outdent | Remove one level of line-leading tabs or spaces. Generally called by block level parsers. |
finalize | Called after block |
See the source code of Extensions
See events and timing information
Ciconia supports HTML/XHTML output. but if you prefer customizing the output,
just create a class that implements Ciconia\Renderer\RendererInterface
.
See Ciconia\Renderer\RendererInterface
Basic Usage: (Outputs result to STDOUT)
ciconia /path/to/file.md
Following command saves result to file:
ciconia /path/to/file.md > /path/to/file.html
Or using pipe (On Windows in does't work):
echo "Markdown is **awesome**" | ciconia
--gfm Activate Gfm extensions
--compress (-c) Remove whitespace between HTML tags
--format (-f) Output format (html|xhtml) (default: "html")
--lint (-l) Syntax check only (lint)
CLI script will be installed in vendor/bin/ciconia
by default.
To change the location:
Yes, there are two ways an alternate vendor binary location can be specified:
- Setting the bin-dir configuration setting in composer.json
- Setting the environment variable COMPOSER_BIN_DIR
http://getcomposer.org/doc/articles/vendor-binaries.md
You can also use single phar file
ciconia.phar /path/to/file.md
If you prefer access this command globally, download ciconia.phar and move it into your PATH
.
mv ciconia.phar /usr/local/bin/ciconia
Install or update dev
dependencies.
php composer.phar update --dev
and run phpunit
The MIT License
Feel free to fork this repository and send a pull request. (A list of contributors)
Kazuyuki Hayashi (@kzykhys)
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论