8000 fix space between preposition "a" and word by zeleznypa · Pull Request #47 · dg/texy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix space between preposition "a" and word #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
.gitattributes export-ignore
.gitignore export-ignore
.github export-ignore
.travis.yml export-ignore
ecs.php export-ignore
ncs.* export-ignore
phpstan.neon export-ignore
tests/ export-ignore

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Nette Code Checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Expand All @@ -21,7 +21,7 @@ jobs:
name: Nette Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php: ['8.0', '8.1', '8.2']

fail-fast: false

name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand All @@ -22,7 +22,7 @@ jobs:
- run: composer install --no-progress --prefer-dist
- run: vendor/bin/tester tests -s -C
- if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: output
path: tests/**/output
Expand All @@ -32,7 +32,7 @@ jobs:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
}
],
"require": {
"php": ">=7.1"
"php": ">=8.0 <8.3"
},
"require-dev": {
"nette/tester": "^2.0",
"tracy/tracy": "^2.4",
"nette/tester": "^2.4",
"tracy/tracy": "^2.8",
"latte/latte": "^2.6 || ^3.0.2",
"phpstan/phpstan": "^0.12"
},
Expand All @@ -31,7 +31,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
"dev-master": "4.0-dev"
}
}
}
5 changes: 1 addition & 4 deletions examples/Figure as Definition List/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
}


/**
* @return Texy\HtmlElement|string|null
*/
function figureHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null, $content, Texy\Modifier $modifier)
function figureHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null, $content, Texy\Modifier $modifier): Texy\HtmlElement|string|null
{
// finish invocation by default way
$el = $invocation->proceed();
Expand Down
3 changes: 1 addition & 2 deletions examples/Youtube video/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@

/**
* User handler for images
* @return Texy\HtmlElement|string|null
*/
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null)
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null): Texy\HtmlElement|string|null
{
$parts = explode(':', $image->URL);
if (count($parts) !== 2) {
Expand Down
14 changes: 5 additions & 9 deletions examples/handler/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ public function image(Texy\HandlerInvocation $invocation, Texy\Image $image, Tex
}


/**
* @param Texy\HandlerInvocation handler invocation
* @return Texy\HtmlElement|string|null
*/
public function linkReference(Texy\HandlerInvocation $invocation, Texy\Link $link, string $content)
public function linkReference(Texy\HandlerInvocation $invocation, Texy\Link $link, string $content): Texy\HtmlElement|string|null
{
return $invocation->proceed();
}
Expand All @@ -83,7 +79,7 @@ public function phrase(
$phrase,
$content,
Texy\Modifier $modifier,
Texy\Link $link = null
Texy\Link $link = null,
) {
return $invocation->proceed();
}
Expand Down Expand Up @@ -134,7 +130,7 @@ public function figure(
Texy\Image $image,
Texy\Link $link = null,
$content,
Texy\Modifier $modifier
Texy\Modifier $modifier,
) {
return $invocation->proceed();
}
Expand All @@ -146,7 +142,7 @@ public function heading(
$level,
$content,
Texy\Modifier $modifier,
$isSurrounded
$isSurrounded,
) {
return $invocation->proceed();
}
Expand Down Expand Up @@ -174,7 +170,7 @@ public function afterList(Texy\BlockParser $parser, Texy\HtmlElement $element, T
public function afterDefinitionList(
Texy\BlockParser $parser,
Texy\HtmlElement $element,
528C Texy\Modifier $modifier
Texy\Modifier $modifier,
): void {
}

Expand Down
3 changes: 1 addition & 2 deletions examples/images/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

/**
* User handler for images
* @return Texy\HtmlElement|string|null
*/
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null)
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null): Texy\HtmlElement|string|null
{
if ($image->URL == 'user') { // accepts only [* user *]
$image->URL = 'image.gif'; // image URL
Expand Down
5 changes: 1 addition & 4 deletions examples/links/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
}


/**
* @return Texy\HtmlElement|string|null
*/
function phraseHandler(Texy\HandlerInvocation $invocation, $phrase, $content, Texy\Modifier $modifier, Texy\Link $link = null)
function phraseHandler(Texy\HandlerInvocation $invocation, $phrase, $content, Texy\Modifier $modifier, Texy\Link $link = null): Texy\HtmlElement|string|null
{
// is there link?
if (!$link) {
Expand Down
5 changes: 2 additions & 3 deletions examples/references/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@

/**
* User handler for unknown reference
* @return Texy\HtmlElement|string|null
*/
function newReferenceHandler(Texy\HandlerInvocation $parser, $refName)
function newReferenceHandler(Texy\HandlerInvocation $parser, $refName): Texy\HtmlElement|string|null
{
$names = ['Me', 'Punkrats', 'Servats', 'Bonifats'];

if (!isset($names[$refName])) {
return; // it's not my job
return null; // it's not my job
}

$name = $names[$refName];
Expand Down
6 changes: 1 addition & 5 deletions examples/syntax highlighting/demo-fshl-alt.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ function blockHandler(Texy\HandlerInvocation $invocation, $blocktype, $content,

/**
* Pattern handler for PHP & JavaScript block syntaxes
*
* @param array $matches regexp matches
* @param string $name pattern name
* @return Texy\HtmlElement|string|null
*/
function codeBlockHandler(Texy\BlockParser $parser, array $matches, string $name)
function codeBlockHandler(Texy\BlockParser $parser, array $matches, string $name): Texy\HtmlElement|string|null
{
[$content] = $matches;
$langClass = $name === 'phpBlockSyntax'
Expand Down
15 changes: 5 additions & 10 deletions examples/user syntax/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,29 @@
$texy->registerLinePattern(
'userInlineHandler', // callback function or method
'#(?<!\*)\*(?!\ |\*)(.+)' . Texy\Patterns::MODIFIER . '?(?<!\ |\*)\*(?!\*)()#U', // regular expression
'myInlineSyntax1' // any syntax name
'myInlineSyntax1', // any syntax name
);

// add new syntax: _italic_
$texy->registerLinePattern(
'userInlineHandler',
'#(?<!_)_(?!\ |_)(.+)' . Texy\Patterns::MODIFIER . '?(?<!\ |_)_(?!_)()#U',
'myInlineSyntax2'
'myInlineSyntax2',
);


// add new syntax: .h1 ...
$texy->registerBlockPattern(
'userBlockHandler',
'#^\.([a-z0-9]+)\n(.+)$#m', // block patterns must be multiline and line-anchored
'myBlockSyntax1'
'myBlockSyntax1',
);


/**
* Pattern handler for inline syntaxes
*
* @param array $matches reg-exp matches
* @param string $name pattern name (myInlineSyntax1 or myInlineSyntax2)
* @return Texy\HtmlElement|string
*/
function userInlineHandler(Texy\LineParser $parser, array $matches, string $name)
function userInlineHandler(Texy\LineParser $parser, array $matches, string $name): Texy\HtmlElement|string
{
[, $mContent, $mMod] = $matches;

Expand Down Expand Up @@ -83,9 +79,8 @@ function userInlineHandler(Texy\LineParser $parser, array $matches, string $name
*
* @param array $matches regexp matches
* @param string $name pattern name (myBlockSyntax1)
* @return Texy\HtmlElement|string|null
*/
function userBlockHandler(Texy\BlockParser $parser, array $matches, string $name)
function userBlockHandler(Texy\BlockParser $parser, array $matches, string $name): Texy\HtmlElement|string|null
{
[, $mTag, $mText] = $matches;

Expand Down
3 changes: 1 addition & 2 deletions src/Bridges/Latte/TexyMacro.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
class TexyMacro extends Latte\Macros\MacroSet
{
/** @var Texy */
private $texy;
private Texy $texy;


public function __construct(Latte\Engine $engine, Texy $texy)
Expand Down
13 changes: 5 additions & 8 deletions src/Texy/BlockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ class BlockParser extends Parser
/** @var array<string, array{handler: callable, pattern: string}> */
public $patterns;

/** @var string */
private $text;
private string $text;

/** @var int */
private $offset;
private int $offset;

/** @var bool */
private $indented;
private bool $indented;


public function __construct(Texy $texy, HtmlElement $element, bool $indented)
Expand Down Expand Up @@ -56,7 +53,7 @@ public function next(string $pattern, &$matches): bool
$this->text,
$pattern . 'Am', // anchored & multiline
Regexp::OFFSET_CAPTURE,
$this->offset
$this->offset,
);

if ($matches) {
Expand Down Expand Up @@ -147,7 +144,7 @@ private function match(string $text): array
$ms = Regexp::match(
$text,
$pattern['pattern'],
Regexp::OFFSET_CAPTURE | Regexp::ALL
Regexp::OFFSET_CAPTURE | Regexp::ALL,
);

foreach ((array) $ms as $m) {
Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Configurator
{
use Strict;

public static $safeTags = [
public static array $safeTags = [
'a' => ['href', 'title'],
'abbr' => ['title'],
'b' => [],
Expand Down
10 changes: 4 additions & 6 deletions src/Texy/HandlerInvocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ final class HandlerInvocation
/** @var array<int, callable> */
private $handlers;

/** @var int callback counter */
private $pos;
/** callback counter */
private int $pos;

/** @var array */
private $args;
private array $args;

/** @var Parser */
private $parser;
private Parser $parser;


public function __construct(array $handlers, Parser $parser, array $args)
Expand Down
6 changes: 5 additions & 1 deletion src/Texy/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
declare(strict_types=1);

namespace Texy;
use Nette\Utils\Strings;


/**
Expand Down Expand Up @@ -94,7 +95,7 @@ public static function toAscii(string $s): string
$s,
"\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2"
. "\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe",
'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt'
'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt',
);
} else {
$s = (string) @iconv('UTF-8', 'ASCII//TRANSLIT', $s); // intentionally @
Expand All @@ -110,6 +111,9 @@ public static function toAscii(string $s): string
*/
public static function webalize(string $s, string $charlist = ''): string
{
if (class_exists(Strings::class)) {
return Strings::webalize($s, $charlist);
}
$s = self::toAscii($s);
$s = strtolower($s);
$s = Regexp::replace($s, '#[^a-z0-9' . preg_quote($charlist, '#') . ']+#', '-');
Expand Down
Loading
0