Add Markdown tables support

This commit is contained in:
Stéphane Goetz 2015-10-21 23:26:42 +02:00
parent 602309b167
commit 9497be3817
7 changed files with 82 additions and 27 deletions

View File

@ -15,9 +15,10 @@
"php": ">=5.4",
"league/plates": "~3.1",
"guzzlehttp/guzzle": "~5.3",
"league/commonmark": "0.8.*",
"league/commonmark": "^0.11",
"symfony/console": "~2.7",
"symfony/finder": "~2.7"
"symfony/finder": "~2.7",
"webuni/commonmark-table-extension": "0.4.*"
},
"autoload": {
"psr-4": {

75
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "7cb7ddabbb3aaa33e7504afc4c7150b9",
"hash": "90ed477bfae85bfdc868d7685b04531d",
"packages": [
{
"name": "guzzlehttp/guzzle",
@ -167,16 +167,16 @@
},
{
"name": "league/commonmark",
"version": "0.8.0",
"version": "0.11.3",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "91696c88df298f75fdd2075e4bb19c6dbd7338ca"
"reference": "d22d6a6a4b049faccc2f8e491cce6076eeb165c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/91696c88df298f75fdd2075e4bb19c6dbd7338ca",
"reference": "91696c88df298f75fdd2075e4bb19c6dbd7338ca",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d22d6a6a4b049faccc2f8e491cce6076eeb165c7",
"reference": "d22d6a6a4b049faccc2f8e491cce6076eeb165c7",
"shasum": ""
},
"require": {
@ -188,16 +188,21 @@
},
"require-dev": {
"erusev/parsedown": "~1.0",
"jgm/commonmark": "0.19",
"jgm/commonmark": "0.22",
"jgm/smartpunct": "0.22",
"michelf/php-markdown": "~1.4",
"mikehaertl/php-shellcommand": "~1.1.0",
"phpunit/phpunit": "~4.3",
"phpunit/phpunit-mock-objects": "2.3.0",
"symfony/finder": "~2.3"
},
"bin": [
"bin/commonmark"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.8-dev"
"dev-master": "0.12-dev"
}
},
"autoload": {
@ -224,7 +229,7 @@
"markdown",
"parser"
],
"time": "2015-04-29 18:01:46"
"time": "2015-09-25 12:40:32"
},
{
"name": "league/plates",
@ -427,6 +432,60 @@
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2015-09-19 19:59:23"
},
{
"name": "webuni/commonmark-table-extension",
"version": "0.4.1",
"source": {
"type": "git",
"url": "https://github.com/webuni/commonmark-table-extension.git",
"reference": "569bdc491abe1dc25f2346e946b19695c4045e18"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webuni/commonmark-table-extension/zipball/569bdc491abe1dc25f2346e946b19695c4045e18",
"reference": "569bdc491abe1dc25f2346e946b19695c4045e18",
"shasum": ""
},
"require": {
"league/commonmark": "^0.11",
"php": ">=5.4"
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.9",
"phpunit/phpunit": "^4.3",
"symfony/var-dumper": "^2.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.4-dev"
}
},
"autoload": {
"psr-4": {
"Webuni\\CommonMark\\TableExtension\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Martin Hasoň",
"email": "martin.hason@gmail.com",
"role": "Lead Developer"
}
],
"description": "The table extension for CommonMark PHP implementation",
"homepage": "https://github.com/webuni/commonmark-table-extension",
"keywords": [
"commonmark",
"markdown",
"table"
],
"time": "2015-09-22 21:06:47"
}
],
"packages-dev": [],

BIN
daux.phar

Binary file not shown.

View File

@ -89,17 +89,10 @@ Or perhaps someone a little less eloquent:
Table for two
-------------
<table>
<tr>
<th>ID</th><th>Name</th><th>Rank</th>
</tr>
<tr>
<td>1</td><td>Tom Preston-Werner</td><td>Awesome</td>
</tr>
<tr>
<td>2</td><td>Albert Einstein</td><td>Nearly as awesome</td>
</tr>
</table>
ID | Name | Rank
---|:------:|------:
1 | Tom Preston-Werner | Awesome
2 | Albert Einstein | Nearly as awesome
Crazy linking action
--------------------

View File

@ -3,6 +3,7 @@
use League\CommonMark\DocParser;
use League\CommonMark\Environment;
use League\CommonMark\HtmlRenderer;
use Webuni\CommonMark\TableExtension\TableExtension;
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
{
@ -15,6 +16,7 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
{
$environment = Environment::createCommonMarkEnvironment();
$environment->mergeConfig($config);
$environment->addExtension(new TableExtension());
$this->extendEnvironment($environment);

View File

@ -1,7 +1,7 @@
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
use League\CommonMark\HtmlElement;
use League\CommonMark\HtmlRendererInterface;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Link;
use Todaymade\Daux\Config;
@ -43,11 +43,11 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
/**
* @param Link $inline
* @param HtmlRendererInterface $htmlRenderer
* @param ElementRendererInterface $htmlRenderer
*
* @return HtmlElement
*/
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
// This can't be in the method type as
// the method is an abstract and should

View File

@ -1,7 +1,7 @@
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
use League\CommonMark\HtmlElement;
use League\CommonMark\HtmlRendererInterface;
use League\CommonMark\ElementRendererInterface;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Inline\Element\Link;
@ -9,11 +9,11 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
{
/**
* @param Link $inline
* @param HtmlRendererInterface $htmlRenderer
* @param ElementRendererInterface $htmlRenderer
*
* @return HtmlElement
*/
public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
// This can't be in the method type as
// the method is an abstract and should