mirror of
https://github.com/KnpLabs/KnpMarkdownBundle.git
synced 2024-05-21 14:56:31 +02:00
merge dev-tac
This commit is contained in:
commit
7afd756126
21
.github/workflows/ci.yml
vendored
Normal file
21
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
name: CI
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: php-actions/composer@v5
|
||||
|
||||
- name: PHPUnit Tests
|
||||
uses: php-actions/phpunit@v9
|
||||
env:
|
||||
TEST_NAME: PHPUNIT
|
||||
with:
|
||||
bootstrap: vendor/autoload.php
|
||||
configuration: phpunit.xml
|
||||
args: --coverage-text
|
36
.github/workflows/php.yml
vendored
Normal file
36
.github/workflows/php.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: PHP Composer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate --strict
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress
|
||||
|
||||
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
|
||||
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
||||
|
||||
- name: Run test suite
|
||||
run: composer run-script test
|
|
@ -12,11 +12,10 @@ class Configuration implements ConfigurationInterface
|
|||
*
|
||||
* @return TreeBuilder
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('knp_markdown');
|
||||
// BC layer for symfony/config < 4.2
|
||||
$rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('knp_markdown');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
|
@ -27,37 +26,6 @@ class Configuration implements ConfigurationInterface
|
|||
->scalarNode('service')->cannotBeEmpty()->defaultValue('markdown.parser.max')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('sundown')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('extensions')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('fenced_code_blocks')->defaultFalse()->end()
|
||||
->booleanNode('no_intra_emphasis')->defaultFalse()->end()
|
||||
->booleanNode('tables')->defaultFalse()->end()
|
||||
->booleanNode('autolink')->defaultFalse()->end()
|
||||
->booleanNode('strikethrough')->defaultFalse()->end()
|
||||
->booleanNode('lax_html_blocks')->defaultFalse()->end()
|
||||
->booleanNode('space_after_headers')->defaultFalse()->end()
|
||||
->booleanNode('superscript')->defaultFalse()->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('render_flags')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('filter_html')->defaultFalse()->end()
|
||||
->booleanNode('no_images')->defaultFalse()->end()
|
||||
->booleanNode('no_links')->defaultFalse()->end()
|
||||
->booleanNode('no_styles')->defaultFalse()->end()
|
||||
->booleanNode('safe_links_only')->defaultFalse()->end()
|
||||
->booleanNode('with_toc_data')->defaultFalse()->end()
|
||||
->booleanNode('hard_wrap')->defaultFalse()->end()
|
||||
->booleanNode('xhtml')->defaultFalse()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end();
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Knp\Bundle\MarkdownBundle\Parser;
|
||||
|
||||
use Knp\Bundle\MarkdownBundle\MarkdownParserInterface;
|
||||
|
||||
use Sundown\Markdown;
|
||||
|
||||
/**
|
||||
* SundownParser
|
||||
*
|
||||
* This class wraps the original Sundown parser to implement the KnpMardownBundle interface
|
||||
*/
|
||||
class SundownParser implements MarkdownParserInterface
|
||||
{
|
||||
private $parser;
|
||||
|
||||
public function __construct(Markdown $parser)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transformMarkdown($text)
|
||||
{
|
||||
return $this->parser->render($text);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@ Provide markdown conversion (based on [Michel Fortin work](https://github.com/mi
|
|||
|
||||
[![Build Status](https://secure.travis-ci.org/KnpLabs/KnpMarkdownBundle.svg)](http://travis-ci.org/KnpLabs/KnpMarkdownBundle)
|
||||
|
||||
![ci.yml](https://github.com/tacman/KnpMarkdownBundle/actions/workflows/ci.yml/badge.svg)
|
||||
![php.yml](https://github.com/tacman/KnpMarkdownBundle/actions/workflows/php.yml/badge.svg)
|
||||
|
||||
## INSTALLATION
|
||||
|
||||
Add KnpMarkdownBundle to your project via [Composer](https://getcomposer.org/):
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="markdown.parser.sundown.class">Knp\Bundle\MarkdownBundle\Parser\SundownParser</parameter>
|
||||
<parameter key="markdown.sundown.base_parser.class">Sundown\Markdown</parameter>
|
||||
<parameter key="markdown.sundown.renderer.class">Sundown\Render\HTML</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="markdown.parser.sundown" class="%markdown.parser.sundown.class%" public="false">
|
||||
<argument type="service" id="markdown.sundown.base_parser" />
|
||||
</service>
|
||||
|
||||
<service id="markdown.sundown.base_parser" public="false" class="%markdown.sundown.base_parser.class%">
|
||||
<argument type="service" id="markdown.sundown.renderer" />
|
||||
<argument>%markdown.sundown.extensions%</argument>
|
||||
</service>
|
||||
|
||||
<service id="markdown.sundown.renderer" public="false" class="%markdown.sundown.renderer.class%">
|
||||
<argument>%markdown.sundown.render_flags%</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
|
@ -18,20 +18,18 @@
|
|||
],
|
||||
|
||||
"require": {
|
||||
"php": "^7.1.3|^8.0",
|
||||
"symfony/framework-bundle": "~3.4|^4.0|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "~3.4|^4.0|^5.0|^6.0",
|
||||
"php": ">= 7.4",
|
||||
"symfony/framework-bundle": "^4.0|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^4.0|^5.0|^6.0",
|
||||
"michelf/php-markdown": "~1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"symfony/phpunit-bridge": "^4.4.0 || ^5.0 || ^6.0",
|
||||
"symfony/templating": "~3.4|^4.0|^5.0|^6.0",
|
||||
"symfony/test-pack": "^1.0"
|
||||
"symfony/templating": "^4.0|^5.0|^6.0",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/twig-bundle": "to use the Twig markdown filter",
|
||||
"ext-sundown": "to use optional support for php-sundown extension instead of php implementation"
|
||||
"symfony/twig-bundle": "to use the Twig markdown filter"
|
||||
},
|
||||
|
||||
"extra": {
|
||||
|
@ -40,6 +38,18 @@
|
|||
}
|
||||
},
|
||||
|
||||
"scripts": {
|
||||
"test": [
|
||||
"php ./vendor/bin/phpunit"
|
||||
]
|
||||
},
|
||||
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Knp\\Bundle\\MarkdownBundle\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Knp\\Bundle\\MarkdownBundle\\": ""
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
|
||||
namespace Knp\Bundle\MarkdownBundle\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;
|
||||
|
||||
class EscapingTest extends \PHPUnit_Framework_TestCase
|
||||
class EscapingTest extends TestCase
|
||||
{
|
||||
protected $parser;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->parser = new Parser();
|
||||
}
|
|
@ -3,8 +3,9 @@
|
|||
namespace Knp\Bundle\MarkdownBundle\Tests;
|
||||
|
||||
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser as Parser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FeatureTest extends \PHPUnit_Framework_TestCase
|
||||
class FeatureTest extends TestCase
|
||||
{
|
||||
public function testParser()
|
||||
{
|
||||
|
@ -754,10 +755,10 @@ EOF;
|
|||
// asserting a few things instead of comparing full final HTML
|
||||
// because a few minor things have changed over versions of Michelf
|
||||
// With assertContains(), tests will pass across all versions
|
||||
$this->assertContains('<p>That\'s some text with a footnote.<sup id="fnref:1"><a href="#fn:1"', $actualHtml);
|
||||
$this->assertContains('<div class="footnotes"', $actualHtml);
|
||||
$this->assertContains('<li id="fn:1"', $actualHtml);
|
||||
$this->assertContains('<p>And that\'s the footnote. <a href="#fnref:1" class="footnote-backref"', $actualHtml);
|
||||
$this->assertStringContainsString('<p>That\'s some text with a footnote.<sup id="fnref:1"><a href="#fn:1"', $actualHtml);
|
||||
$this->assertStringContainsString('<div class="footnotes"', $actualHtml);
|
||||
$this->assertStringContainsString('<li id="fn:1"', $actualHtml);
|
||||
$this->assertStringContainsString('<p>And that\'s the footnote. <a href="#fnref:1" class="footnote-backref"', $actualHtml);
|
||||
}
|
||||
|
||||
/**
|
|
@ -4,14 +4,16 @@ namespace Knp\Bundle\MarkdownBundle\Tests;
|
|||
|
||||
use Knp\Bundle\MarkdownBundle\KnpMarkdownBundle;
|
||||
use Knp\Bundle\MarkdownBundle\Parser\MarkdownParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
|
||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||
|
||||
class IntegrationTest extends \PHPUnit_Framework_TestCase
|
||||
class IntegrationTest extends TestCase
|
||||
{
|
||||
public function testServicesAvailable()
|
||||
{
|
||||
|
@ -37,13 +39,17 @@ class IntegrationKernel extends Kernel
|
|||
];
|
||||
}
|
||||
|
||||
protected function configureRoutes(RouteCollectionBuilder $routes)
|
||||
protected function configureRoutes(RoutingConfigurator $routes)
|
||||
{
|
||||
}
|
||||
|
||||
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
|
||||
{
|
||||
$c->setParameter('kernel.secret', '1234');
|
||||
|
||||
$c->loadFromExtension('framework', [
|
||||
'secret' => 'F00',
|
||||
'router' => ['utf8' => true]
|
||||
]);
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
|
@ -5,8 +5,9 @@ namespace Knp\Bundle\MarkdownBundle\Tests\Parser;
|
|||
use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;
|
||||
use Knp\Bundle\MarkdownBundle\Tests\fixtures\app\TestKernel;
|
||||
use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ParserManagerTest extends \PHPUnit_Framework_TestCase
|
||||
class ParserManagerTest extends TestCase
|
||||
{
|
||||
public function testIntegration()
|
||||
{
|
|
@ -3,8 +3,9 @@
|
|||
namespace Knp\Bundle\MarkdownBundle\Tests;
|
||||
|
||||
use Knp\Bundle\MarkdownBundle\Parser\Preset as Preset;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PresetTest extends \PHPUnit_Framework_TestCase
|
||||
class PresetTest extends TestCase
|
||||
{
|
||||
public function testMax()
|
||||
{
|
Loading…
Reference in a new issue