Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,39 @@ on:
pull_request:
branches: [ master ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2]
php: ['8.1', '8.2', '8.3', '8.4', '8.5']

name: PHP ${{ matrix.php }}
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v1
tools: composer:v2
coverage: none

- name: Install Dependencies
run: composer update

- name: Run phpunit tests
run: |
mkdir -p build/logs
vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml
run: vendor/bin/phpunit --stop-on-error

- name: Run phpcs
run: composer cs

- name: Run phpstan
run: composer static

- name: Coverage upload
if: matrix.php == '7.4'
run: bash <(curl -s https://codecov.io/bash)

16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ CLI Markdown Renderer
<?php
require_once 'vendor/autoload.php';

use League\CommonMark\DocParser;
use League\CommonMark\Environment;
use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\CommonMarkCoreExtension;
use League\CommonMark\Parser\MarkdownParser;
use PhpSchool\CliMdRenderer\CliRendererFactory;

$parser = new DocParser(Environment::createCommonMarkEnvironment());
$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension());

$parser = new MarkdownParser($environment);
$cliRenderer = (new CliRendererFactory)->__invoke();
$ast = $parser->parse(file_get_contents('path/to/file.md'));

Expand All @@ -26,7 +30,7 @@ echo $cliRenderer->renderBlock($ast);
### Syntax Highlighting

`FencedCode` can be syntax highlighted. By default only PHP source code is Syntax Highlighted using: [kadet/keylighter](https://github.com/kadet1090/KeyLighter)
If you want to add syntax highlighting for other languages you should create a class which implements `\AydinHassan\CliMdRenderer\SyntaxHighlighterInterface`
If you want to add syntax highlighting for other languages you should create a class which implements `\PhpSchool\CliMdRenderer\SyntaxHighlighterInterface`

It accepts code as a string and should return highlighted code as a string. You register your highlighter like so

Expand All @@ -46,7 +50,9 @@ If you need to do this you cannot use the factory so construction will look some
require_once 'vendor/autoload.php';

use Colors\Color;
use League\CommonMark\Environment;
use League\CommonMark\Environment\Environment;
use PhpSchool\CliMdRenderer\CliExtension;
use PhpSchool\CliMdRenderer\CliRenderer;

$environment = new Environment();
$environment->addExtension(new CliExtension());
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
}
],
"require" : {
"php" : ">=7.1",
"league/commonmark": "^1.5.6",
"php-school/keylighter": "^0.8.4",
"php" : "^8.1",
"league/commonmark": "^2.8",
"nette/schema": "^1.2",
"php-school/keylighter": "^0.8.5",
"kevinlebrun/colors.php": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0 | ^8.0 | ^9.0",
"squizlabs/php_codesniffer": "^3.0",
"phpstan/phpstan": "^0.12.50"
"phpunit/phpunit": "^10.5 || ^11.5 || ^12.0",
"squizlabs/php_codesniffer": "^3.10",
"phpstan/phpstan": "^2.1"
},
"autoload" : {
"psr-4" : {
Expand Down
Loading
Loading