Skip to content

Commit

Permalink
Housekeep
Browse files Browse the repository at this point in the history
* PHP 8
* PHPStan 0.12.
* ninjify/qa 0.12
* ninjify/nunjuck 0.4
* new Makefile
* new README
  • Loading branch information
radimvaculik authored and f3l1x committed Feb 6, 2021
1 parent 0fa0760 commit fc96a19
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 80 deletions.
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
.PHONY: qa lint cs csf phpstan tests coverage
.PHONY: install qa cs csf phpstan tests coverage-clover coverage-html

all:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
install:
composer update

vendor: composer.json composer.lock
composer install
qa: phpstan cs

qa: lint phpstan cs

lint: vendor
vendor/bin/linter src tests

cs: vendor
cs:
ifdef GITHUB_ACTION
vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr
else
vendor/bin/codesniffer src tests
endif

csf: vendor
csf:
vendor/bin/codefixer src tests

phpstan: vendor
phpstan:
vendor/bin/phpstan analyse -l max -c phpstan.neon src

tests: vendor
tests:
vendor/bin/tester -s -p php --colors 1 -C tests/cases

coverage: vendor
coverage-clover:
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/cases

coverage-html:
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests/cases
84 changes: 38 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# Latte > Parsedown/Markdown

:tractor: Markdown parser to Nette Framework.

-----

[![Build Status](https://img.shields.io/travis/contributte/latte-parsedown-extra.svg?style=flat-square)](https://travis-ci.org/contributte/latte-parsedown-extra)
[![Code coverage](https://img.shields.io/coveralls/contributte/latte-parsedown-extra.svg?style=flat-square)](https://coveralls.io/r/contributte/latte-parsedown-extra)
[![Licence](https://img.shields.io/packagist/l/contributte/latte-parsedown-extra.svg?style=flat-square)](https://packagist.org/packages/contributte/latte-parsedown-extra)
[![Downloads this Month](https://img.shields.io/packagist/dm/contributte/latte-parsedown-extra.svg?style=flat-square)](https://packagist.org/packages/contributte/latte-parsedown-extra)
[![Downloads total](https://img.shields.io/packagist/dt/contributte/latte-parsedown-extra.svg?style=flat-square)](https://packagist.org/packages/contributte/latte-parsedown-extra)
[![Latest stable](https://img.shields.io/packagist/v/contributte/latte-parsedown-extra.svg?style=flat-square)](https://packagist.org/packages/contributte/latte-parsedown-extra)
[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)

## Discussion / Help

[![Join the chat](https://img.shields.io/gitter/room/contributte/contributte.svg?style=flat-square)](http://bit.ly/ctteg)

## Install
![](https://heatbadger.now.sh/github/readme/contributte/latte-parsedown-extra/)

<p align=center>
<a href="https://github.com/contributte/latte-parsedown-extra/actions"><img src="https://badgen.net/github/checks/contributte/latte-parsedown-extra"></a>
<a href="https://coveralls.io/r/contributte/latte-parsedown-extra"><img src="https://badgen.net/coveralls/c/github/contributte/latte-parsedown-extra"></a>
<a href="https://packagist.org/packages/contributte/latte-parsedown-extra"><img src="https://badgen.net/packagist/dm/contributte/latte-parsedown-extra"></a>
<a href="https://packagist.org/packages/contributte/latte-parsedown-extra"><img src="https://badgen.net/packagist/v/contributte/latte-parsedown-extra"></a>
</p>
<p align=center>
<a href="https://packagist.org/packages/contributte/latte-parsedown-extra"><img src="https://badgen.net/packagist/php/contributte/latte-parsedown-extra"></a>
<a href="https://github.com/contributte/latte-parsedown-extra"><img src="https://badgen.net/github/license/contributte/latte-parsedown-extra"></a>
<a href="https://bit.ly/ctteg"><img src="https://badgen.net/badge/support/gitter/cyan"></a>
<a href="https://bit.ly/cttfo"><img src="https://badgen.net/badge/support/forum/yellow"></a>
<a href="https://contributte.org/partners.html"><img src="https://badgen.net/badge/sponsor/donations/F96854"></a>
</p>

<p align=center>
Website 🚀 <a href="https://contributte.org">contributte.org</a> | Contact 👨🏻‍💻 <a href="https://f3l1x.io">f3l1x.io</a> | Twitter 🐦 <a href="https://twitter.com/contributte">@contributte</a>
</p>

## Usage

To install latest version of `contributte/latte-parsedown-extra` use [Composer](https://getcomposer.com).

```
composer require contributte/latte-parsedown-extra
```

## Documentation

For details on how to use this package, check out our [documentation](.docs).

## Versions

| State | Version | Branch | PHP |
Expand All @@ -31,34 +39,18 @@ composer require contributte/latte-parsedown-extra
| stable | `^1.4.0` | `master` | `>= 7.1` |
| stable | `^1.2.0` | `master` | `>= 5.6` |

## Overview
## Development

- [Usage - how to install](https://github.com/contributte/latte-parsedown-extra/blob/master/.docs/README.md#usage)
- [Extension - how to configure](https://github.com/contributte/latte-parsedown-extra/blob/master/.docs/README.md#configuration)
See [how to contribute](https://contributte.org) to this package. This package is currently maintained by these authors.

## Maintainers
<a href="https://github.com/f3l1x">
<img width="80" height="80" src="https://avatars.githubusercontent.com/f3l1x">
</a>
<a href="https://github.com/mabar">
<img width="80" height="80" src="https://avatars.githubusercontent.com/mabar">
</a>

<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/f3l1x">
<img width="150" height="150" src="https://avatars2.githubusercontent.com/u/538058?v=3&s=150">
</a>
</br>
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
</td>
<td align="center">
<a href="https://github.com/mabar">
<img width="150" height="150" src="https://avatars0.githubusercontent.com/u/20974277?s=150&v=4">
</a>
</br>
<a href="https://github.com/mabar">Marek Bartoš</a>
</td>
</tr>
</tbody>
</table>

---
-----

Thank you for testing, reporting and contributing.
Consider to [support](https://contributte.org/partners) **contributte** development team.
Also thank you for using this package.
15 changes: 7 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@
}
],
"require": {
"php": "^7.2",
"php": ">=7.2",
"erusev/parsedown": "~1.7.3",
"erusev/parsedown-extra": "^0.7.1|^0.8.0",
"latte/latte": "~2.5.1|~2.6.0|~2.7.0|~2.8.0",
"nette/di": "^3.0",
"nette/utils": "~3.0.0|~3.1.0"
},
"require-dev": {
"ninjify/qa": "^0.9",
"ninjify/nunjuck": "^0.2",
"ninjify/qa": "^0.12",
"ninjify/nunjuck": "^0.4",
"nette/application": "~3.0.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-nette": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11"
"phpstan/phpstan-deprecation-rules": "^0.12",
"phpstan/phpstan-nette": "^0.12",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includes:
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
14 changes: 6 additions & 8 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?xml version="1.0"?>
<ruleset>
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml">
<exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/>
</rule>
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>

<!-- Specific rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
src=>Contributte\Parsedown,
tests/fixtures=>Tests\Fixtures,
"/>
<property name="rootNamespaces" type="array">
<element key="src" value="Contributte\Parsedown"/>
<element key="tests/cases" value="Tests\Cases"/>
</property>
</properties>
</rule>

<!-- Exclude folders -->
<!--Exclude folders -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>
2 changes: 1 addition & 1 deletion src/DI/ParsedownExtraExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Nette\Bridges\ApplicationLatte\ILatteFactory;
use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\FactoryDefinition;
use Nette\DI\Statement;
use Nette\DI\Definitions\Statement;
use Nette\InvalidStateException;
use Nette\Schema\Expect;
use Nette\Schema\Schema;
Expand Down
2 changes: 1 addition & 1 deletion src/ParsedownExtraAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ParsedownExtraAdapter
*/
public function __construct(?ParsedownExtra $parsedown = null)
{
$this->parsedown = $parsedown ?: new ParsedownExtra();
$this->parsedown = $parsedown ?? new ParsedownExtra();
}

/**
Expand Down
7 changes: 7 additions & 0 deletions src/ParsedownFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Contributte\Parsedown;

use Exception;
use Latte\Engine;
use Latte\Runtime\FilterInfo;

class ParsedownFilter
Expand All @@ -16,10 +18,15 @@ public function __construct(ParsedownExtraAdapter $adapter)
}

/**
* @param FilterInfo $info
* @param mixed $text
*/
public function apply(FilterInfo $info, $text): string
{
if ($info->contentType !== Engine::CONTENT_HTML) {
throw new Exception('Filter |parsedown used in incompatible content type.');
}

return $this->adapter->process($text);
}

Expand Down
4 changes: 3 additions & 1 deletion tests/cases/ParsedownExtraAdapter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ test(function (): void {
# Headline
## Headline2
* 1
';

Assert::equal("<h1>Headline</h1>\n<h2>Headline2</h2>", $adapter->process($text));
Assert::equal("<h1>Headline</h1>\n<h2>Headline2</h2>\n<ul>\n<li>1</li>\n</ul>", $adapter->process($text));
});

0 comments on commit fc96a19

Please sign in to comment.