Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jan 21, 2025
1 parent a441883 commit 084aee8
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/Figure as Definition List/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}


function figureHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null, $content, Texy\Modifier $modifier): Texy\HtmlElement|string|null
function figureHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, ?Texy\Link $link, $content, Texy\Modifier $modifier): Texy\HtmlElement|string|null
{
// finish invocation by default way
$el = $invocation->proceed();
Expand Down
2 changes: 1 addition & 1 deletion examples/Youtube video/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* User handler for images
*/
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null): Texy\HtmlElement|string|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
2 changes: 1 addition & 1 deletion examples/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "project",
"require": {
"php": ">=7.1",
"php": ">=8.1",
"texy/texy": "^3.0",
"kukulich/fshl": "^2.1",
"geshi/geshi": "^1.0"
Expand Down
8 changes: 4 additions & 4 deletions examples/handler/handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function emoticon(Texy\HandlerInvocation $invocation, $emoticon, $rawEmot


/** @return Texy\HtmlElement|string|null */
public function image(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null)
public function image(Texy\HandlerInvocation $invocation, Texy\Image $image, ?Texy\Link $link = null)
{
return $invocation->proceed();
}
Expand All @@ -55,7 +55,7 @@ public function image(Texy\HandlerInvocation $invocation, Texy\Image $image, Tex
public function linkReference(
Texy\HandlerInvocation $invocation,
Texy\Link $link,
string $content
string $content,
): Texy\HtmlElement|string|null
{
return $invocation->proceed();
Expand All @@ -82,7 +82,7 @@ public function phrase(
$phrase,
$content,
Texy\Modifier $modifier,
Texy\Link $link = null,
?Texy\Link $link = null,
) {
return $invocation->proceed();
}
Expand Down Expand Up @@ -131,7 +131,7 @@ function paragraph(Texy\HandlerInvocation $invocation, $content, Texy\Modifier $
public function figure(
Texy\HandlerInvocation $invocation,
Texy\Image $image,
Texy\Link $link = null,
?Texy\Link $link,
$content,
Texy\Modifier $modifier,
) {
Expand Down
2 changes: 1 addition & 1 deletion examples/images/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* User handler for images
*/
function imageHandler(Texy\HandlerInvocation $invocation, Texy\Image $image, Texy\Link $link = null): Texy\HtmlElement|string|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
2 changes: 1 addition & 1 deletion examples/links/demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
}


function phraseHandler(Texy\HandlerInvocation $invocation, $phrase, $content, Texy\Modifier $modifier, Texy\Link $link = null): Texy\HtmlElement|string|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
6 changes: 3 additions & 3 deletions examples/syntax highlighting/demo-fshl-alt.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ function codeBlockHandler(Texy\BlockParser $parser, array $matches, string $name
// add new syntax: <?php ... ? >
$texy->registerBlockPattern(
'codeBlockHandler',
'#^<\\?php\n.+?\n\\?>$#ms', // block patterns must be multiline and line-anchored
'phpBlockSyntax'
'#^<\?php\n.+?\n\?>$#ms', // block patterns must be multiline and line-anchored
'phpBlockSyntax',
);

// add new syntax: <script ...> ... </script>
$texy->registerBlockPattern(
'codeBlockHandler',
'#^<script(?: type=.?text/javascript.?)?>\n.+?\n</script>$#ms', // block patterns must be multiline and line-anchored
'scriptBlockSyntax'
'scriptBlockSyntax',
);

// processing
Expand Down
4 changes: 2 additions & 2 deletions src/Texy/Modules/BlockModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(Texy\Texy $texy)

$texy->registerBlockPattern(
$this->pattern(...),
'#^/--++ *+(.*)' . Texy\Patterns::MODIFIER_H . '?$((?:\n(?0)|\n.*+)*)(?:\n\\\\--.*$|\z)#mUi',
'#^/--++ *+(.*)' . Texy\Patterns::MODIFIER_H . '?$((?:\n(?0)|\n.*+)*)(?:\n\\\--.*$|\z)#mUi',
'blocks',
);
}
Expand All @@ -52,7 +52,7 @@ private function beforeBlockParse(Texy\BlockParser $parser, string &$text): void
// autoclose exclusive blocks
$text = Texy\Regexp::replace(
$text,
'#^(/--++ *+(?!div|texysource).*)$((?:\n.*+)*?)(?:\n\\\\--.*$|(?=(\n/--.*$)))#mi',
'#^(/--++ *+(?!div|texysource).*)$((?:\n.*+)*?)(?:\n\\\--.*$|(?=(\n/--.*$)))#mi',
"\$1\$2\n\\--",
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Texy/Modules/PhraseModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public function __construct(Texy\Texy $texy)
// ***strong+emphasis***
$texy->registerLinePattern(
$this->patternPhrase(...),
'#(?<![*\\\\])\*\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\\])\*\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'#(?<![*\\\])\*\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'phrase/strong+em',
);

// **strong**
$texy->registerLinePattern(
$this->patternPhrase(...),
'#(?<![*\\\\])\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\\])\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'#(?<![*\\\])\*\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'phrase/strong',
);

Expand All @@ -82,14 +82,14 @@ public function __construct(Texy\Texy $texy)
// *emphasisAlt*
$texy->registerLinePattern(
$this->patternPhrase(...),
'#(?<![*\\\\])\*(?![\s*])((?:[^\s*]++|[*])+)' . Patterns::MODIFIER . '?(?<![\s*\\\\])\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'#(?<![*\\\])\*(?![\s*])((?:[^\s*]++|[*])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?!\*)(?::(' . Patterns::LINK_URL . '))??()#Uus',
'phrase/em-alt',
);

// *emphasisAlt2*
$texy->registerLinePattern(
$this->patternPhrase(...),
'#(?<![^\s.,;:<>()"\'' . Patterns::MARK . '-])\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\\])\*(?![^\s.,;:<>()"?!\'-])(?::(' . Patterns::LINK_URL . '))??()#Uus',
'#(?<![^\s.,;:<>()"\'' . Patterns::MARK . '-])\*(?![\s*])((?:[^ *]++|[ *])+)' . Patterns::MODIFIER . '?(?<![\s*\\\])\*(?![^\s.,;:<>()"?!\'-])(?::(' . Patterns::LINK_URL . '))??()#Uus',
'phrase/em-alt2',
);

Expand Down
2 changes: 1 addition & 1 deletion src/Texy/Modules/TypographyModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final class TypographyModule extends Texy\Module
private static array $patterns = [
'#(?<![.\x{2026}])\.{3,4}(?![.\x{2026}])#mu' => "\u{2026}", // ellipsis ...
'#(?<=[\d ]|^)-(?=[\d ]|$)#' /*. */ => "\u{2013}", // en dash 123-123
'#(?<=[^!*+,/:;<=>@\\\\_|-])--(?=[^!*+,/:;<=>@\\\\_|-])#' => "\u{2013}", // en dash alphanum--alphanum
'#(?<=[^!*+,/:;<=>@\\\_|-])--(?=[^!*+,/:;<=>@\\\_|-])#' => "\u{2013}", // en dash alphanum--alphanum
'#,-#' /*. */ => ",\u{2013}", // en dash ,-
'#(?<!\d)(\d{1,2}\.) (\d{1,2}\.) (\d\d)#' => "\$1\u{A0}\$2\u{A0}\$3", // date 23. 1. 1978
'#(?<!\d)(\d{1,2}\.) (\d{1,2}\.)#' /*. */ => "\$1\u{A0}\$2", // date 23. 1.
Expand Down

0 comments on commit 084aee8

Please sign in to comment.