From 6e357620da31b6c417d460a30eaeb59959110421 Mon Sep 17 00:00:00 2001
From: Thomas Skerbis
Date: Mon, 2 Sep 2024 15:54:18 +0200
Subject: [PATCH] VendorUpdate to 4.1.2
---
composer.json | 2 +-
composer.lock | 22 +-
vendor/netcarver/textile/CHANGELOG.textile | 22 ++
vendor/netcarver/textile/LICENSE | 2 +-
vendor/netcarver/textile/Makefile | 82 ------
vendor/netcarver/textile/README.textile | 4 +
vendor/netcarver/textile/composer.json | 13 +-
vendor/netcarver/textile/docker-compose.yml | 14 --
vendor/netcarver/textile/phpstan.neon | 6 -
.../textile/sonar-project.properties | 8 -
.../textile/src/Netcarver/Textile/DataBag.php | 2 +-
.../textile/src/Netcarver/Textile/Parser.php | 235 +++++++++++++-----
.../textile/src/Netcarver/Textile/Tag.php | 4 +-
13 files changed, 219 insertions(+), 197 deletions(-)
delete mode 100644 vendor/netcarver/textile/Makefile
delete mode 100644 vendor/netcarver/textile/docker-compose.yml
delete mode 100644 vendor/netcarver/textile/phpstan.neon
delete mode 100644 vendor/netcarver/textile/sonar-project.properties
diff --git a/composer.json b/composer.json
index d195574..df209d9 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,5 @@
{
"require": {
- "netcarver/textile": "^3.7.6"
+ "netcarver/textile": ">=3"
}
}
diff --git a/composer.lock b/composer.lock
index 8bb06b0..744cb80 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,35 +4,36 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "dd220169204bc152c8f96dbb94af36ce",
+ "content-hash": "1cf24fdb102df7d74034643ff1d0eefa",
"packages": [
{
"name": "netcarver/textile",
- "version": "v3.7.7",
+ "version": "v4.1.2",
"source": {
"type": "git",
"url": "https://github.com/textile/php-textile.git",
- "reference": "e5c32b4485741e656cfd94932da8ba7dd4a19da5"
+ "reference": "ddedb2becc2b0ebe932eb0c575e54077b2ca7819"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/textile/php-textile/zipball/e5c32b4485741e656cfd94932da8ba7dd4a19da5",
- "reference": "e5c32b4485741e656cfd94932da8ba7dd4a19da5",
+ "url": "https://api.github.com/repos/textile/php-textile/zipball/ddedb2becc2b0ebe932eb0c575e54077b2ca7819",
+ "reference": "ddedb2becc2b0ebe932eb0c575e54077b2ca7819",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
- "phpstan/phpstan": "1.6.3",
+ "phpstan/phpstan": "1.12.0",
"phpunit/phpunit": "^9.5.20",
+ "psy/psysh": "^0.12.4",
"squizlabs/php_codesniffer": "3.*",
- "symfony/yaml": "^4.4.3"
+ "symfony/yaml": "^5.4.40"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "3.7-dev"
+ "dev-master": "4.1-dev"
}
},
"autoload": {
@@ -58,12 +59,11 @@
"textile"
],
"support": {
- "irc": "irc://irc.freenode.net/textile",
"issues": "https://github.com/textile/php-textile/issues",
"source": "https://github.com/textile/php-textile",
"wiki": "https://github.com/textile/php-textile/wiki"
},
- "time": "2022-05-01T17:05:16+00:00"
+ "time": "2024-08-29T16:28:26+00:00"
}
],
"packages-dev": [],
@@ -74,5 +74,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.6.0"
}
diff --git a/vendor/netcarver/textile/CHANGELOG.textile b/vendor/netcarver/textile/CHANGELOG.textile
index 6f13c2e..ca29165 100644
--- a/vendor/netcarver/textile/CHANGELOG.textile
+++ b/vendor/netcarver/textile/CHANGELOG.textile
@@ -2,6 +2,28 @@ h1. Changelog
Here's a summary of changes in each release. The list doesn't include some small changes or updates to test cases.
+h2. "Version 4.1.2 - 2024/08/29":https://github.com/textile/php-textile/releases/tag/v4.1.2
+
+* Fix PHP 8.4 compatibility issues (closes "#227":https://github.com/textile/php-textile/issues/227).
+
+h2. "Version 4.1.1 - 2024/06/07":https://github.com/textile/php-textile/releases/tag/v4.1.1
+
+* Links are now rendered when block tags are disabled (closes "#225":https://github.com/textile/php-textile/issues/225).
+
+h2. "Version 4.1.0 - 2024/01/02":https://github.com/textile/php-textile/releases/tag/v4.1.0
+
+* Support @:@ and @!@ characters in CSS class names (closes "#224":https://github.com/textile/php-textile/issues/224).
+* Support including textile escape sequences inside link title attribute (closes "#223":https://github.com/textile/php-textile/issues/223).
+
+h2. "Version 4.0.0 - 2022/12/03":https://github.com/textile/php-textile/releases/tag/v4.0.0
+
+* HTML void tags render a self-closing slash based on the given document type. If @Parser::setDocumentType()@ is given @Parser::DOCTYPE_XHTML@, self-closing tags are used, otherwise not.
+
+h2. "Version 3.8.0 - 2022/12/03":https://github.com/textile/php-textile/releases/tag/v3.8.0
+
+* Added @Parser::setAlignClasses()@ and @Parser::isAlignClassesEnabled()@. This can be used to enable img alignment classes in XHTML output document mode, instead of the default align attribute.
+* Added @Parser::DOCTYPE_HTML5@ and @Parser::DOCTYPE_XHTML@ constants. These can be used with @Parser::setDocumentType()@ to specify the output document type.
+
h2. "Version 3.7.7 - 2022/05/01":https://github.com/textile/php-textile/releases/tag/v3.7.7
* Fix deprecation errors that appear on PHP >= 8.1 about preg_split limit argument's NULL value.
diff --git a/vendor/netcarver/textile/LICENSE b/vendor/netcarver/textile/LICENSE
index 14171cc..3a1acaa 100644
--- a/vendor/netcarver/textile/LICENSE
+++ b/vendor/netcarver/textile/LICENSE
@@ -11,7 +11,7 @@ Additions and fixes Copyright (c) 2010 Stef Dawson https://stefdawson.c
Additions and fixes Copyright (c) 2010-17 Netcarver https://github.com/netcarver
Additions and fixes Copyright (c) 2011 Jeff Soo http://ipsedixit.net/
Additions and fixes Copyright (c) 2012 Robert Wetzlmayr https://wetzlmayr.com/
-Additions and fixes Copyright (c) 2012-19 Jukka Svahn https://rahforum.biz/
+Additions and fixes Copyright (c) 2012-24 Jukka Svahn https://rahforum.biz/
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/vendor/netcarver/textile/Makefile b/vendor/netcarver/textile/Makefile
deleted file mode 100644
index e41115a..0000000
--- a/vendor/netcarver/textile/Makefile
+++ /dev/null
@@ -1,82 +0,0 @@
-.PHONY: all clean help lint lint-fix test test-static test-unit bump bump-dev process-reports
-
-IMAGE?=php_8_1
-PHP = docker-compose run --rm $(IMAGE)
-
-all: test
-
-vendor:
- $(PHP) composer install
-
-clean:
- $(PHP) rm -rf vendor composer.lock
-
-lint: vendor
- $(PHP) composer lint
-
-lint-fix: vendor
- $(PHP) composer lint-fix
-
-test: vendor
- $(PHP) composer test
-
-test-static: vendor
- $(PHP) composer test:static
-
-test-unit: vendor
- $(PHP) composer test:unit
-
-bump: vendor
- $(PHP) composer bump
-
-bump-dev: vendor
- $(PHP) composer bump-dev
-
-process-reports:
- $(PHP) bash -c "test -e build/logs/clover.xml && sed -i 's/\/app\///' build/logs/clover.xml"
-
-help:
- @echo "Manage project"
- @echo ""
- @echo "Usage:"
- @echo " $$ make [command] ["
- @echo " IMAGE="
- @echo " ]"
- @echo ""
- @echo "Commands:"
- @echo ""
- @echo " $$ make lint"
- @echo " Lint code style"
- @echo ""
- @echo " $$ make lint-fix"
- @echo " Lint and fix code style"
- @echo ""
- @echo " $$ make test"
- @echo " Run linter, static and unit tests"
- @echo ""
- @echo " $$ make test-unit"
- @echo " Run unit tests"
- @echo ""
- @echo " $$ make test-static"
- @echo " Run static tests"
- @echo ""
- @echo " $$ make bump"
- @echo " Bump version"
- @echo ""
- @echo " $$ make bump-dev"
- @echo " Bump development version"
- @echo ""
- @echo " $$ make clean"
- @echo " Delete installed dependencies"
- @echo ""
- @echo " $$ make vendor"
- @echo " Install dependencies"
- @echo ""
- @echo " $$ make process-reports"
- @echo " Formats test reports to use relative local file paths"
- @echo ""
- @echo "Environment variables:"
- @echo ""
- @echo " IMAGE"
- @echo " docker-compose service name that is used to run the command"
- @echo ""
diff --git a/vendor/netcarver/textile/README.textile b/vendor/netcarver/textile/README.textile
index ef8db27..b5504bf 100644
--- a/vendor/netcarver/textile/README.textile
+++ b/vendor/netcarver/textile/README.textile
@@ -77,3 +77,7 @@ $parser
h2. Getting in contact
The PHP-Textile project welcomes constructive input and bug reports from users. Please "open an issue":https://github.com/textile/php-textile/issues on the repository for a comment, feature request or bug.
+
+h2. Development
+
+See "CONTRIBUTING.textile":https://github.com/textile/php-textile/blob/master/.github/CONTRIBUTING.textile.
diff --git a/vendor/netcarver/textile/composer.json b/vendor/netcarver/textile/composer.json
index 0632b99..8d6899c 100644
--- a/vendor/netcarver/textile/composer.json
+++ b/vendor/netcarver/textile/composer.json
@@ -5,7 +5,6 @@
"homepage": "https://github.com/textile/php-textile",
"keywords": ["php-textile", "textile", "parser", "markup", "language", "html", "format", "plaintext", "document"],
"support": {
- "irc": "irc://irc.freenode.net/textile",
"wiki": "https://github.com/textile/php-textile/wiki",
"issues": "https://github.com/textile/php-textile/issues",
"source": "https://github.com/textile/php-textile"
@@ -24,14 +23,15 @@
"php": ">=5.3.0"
},
"require-dev": {
- "phpstan/phpstan": "1.6.3",
+ "phpstan/phpstan": "1.12.0",
"phpunit/phpunit": "^9.5.20",
"squizlabs/php_codesniffer": "3.*",
- "symfony/yaml": "^4.4.3"
+ "symfony/yaml": "^5.4.40",
+ "psy/psysh": "^0.12.4"
},
"extra": {
"branch-alias": {
- "dev-master": "3.7-dev"
+ "dev-master": "4.1-dev"
}
},
"scripts": {
@@ -40,10 +40,11 @@
"@composer test:static",
"@composer test:unit"
],
- "bump": "@php ./scripts/release.php",
- "bump-dev": "@php ./scripts/release.php --dev",
+ "project:bump": "@php ./scripts/release.php",
+ "project:bump-dev": "@php ./scripts/release.php --dev",
"lint": "phpcs",
"lint-fix": "phpcbf",
+ "repl": "psysh",
"test:static": "phpstan analyse --level 8 src",
"test:unit": "XDEBUG_MODE=coverage phpunit"
}
diff --git a/vendor/netcarver/textile/docker-compose.yml b/vendor/netcarver/textile/docker-compose.yml
deleted file mode 100644
index a2928fd..0000000
--- a/vendor/netcarver/textile/docker-compose.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-version: '3'
-
-services:
- php_8_1:
- build: ./docker/image/php/8_1
- volumes:
- - .:/app
- - ${COMPOSER_HOME:-$HOME/.composer}:/tmp
- networks:
- - app
-
-networks:
- app:
- driver: bridge
diff --git a/vendor/netcarver/textile/phpstan.neon b/vendor/netcarver/textile/phpstan.neon
deleted file mode 100644
index 3e8a951..0000000
--- a/vendor/netcarver/textile/phpstan.neon
+++ /dev/null
@@ -1,6 +0,0 @@
-parameters:
- ignoreErrors:
- - '#Parameter \#2 \$callback of function preg_replace_callback#'
- - "#Cannot access offset '[a-zA-Z0-9\\_]+' on non-empty-array#"
- - '#Cannot access offset [0-9]+ on array#'
- - "#Offset '[a-zA-Z0-9\\_]+' does not exist on array#"
diff --git a/vendor/netcarver/textile/sonar-project.properties b/vendor/netcarver/textile/sonar-project.properties
deleted file mode 100644
index 410f703..0000000
--- a/vendor/netcarver/textile/sonar-project.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-sonar.organization=textile
-sonar.projectKey=textile_php-textile
-sonar.projectName=PHP-Textile
-
-sonar.sources=src
-sonar.tests=test
-sonar.sourceEncoding=UTF-8
-sonar.php.coverage.reportPaths=build/logs/clover.xml
diff --git a/vendor/netcarver/textile/src/Netcarver/Textile/DataBag.php b/vendor/netcarver/textile/src/Netcarver/Textile/DataBag.php
index 933630e..3c89e1f 100644
--- a/vendor/netcarver/textile/src/Netcarver/Textile/DataBag.php
+++ b/vendor/netcarver/textile/src/Netcarver/Textile/DataBag.php
@@ -64,7 +64,7 @@ class DataBag
*
* @param array|null $data The initial data array stored in the bag
*/
- public function __construct(array $data = null)
+ public function __construct($data = null)
{
$this->data = (array) $data;
}
diff --git a/vendor/netcarver/textile/src/Netcarver/Textile/Parser.php b/vendor/netcarver/textile/src/Netcarver/Textile/Parser.php
index 0d05241..035d130 100644
--- a/vendor/netcarver/textile/src/Netcarver/Textile/Parser.php
+++ b/vendor/netcarver/textile/src/Netcarver/Textile/Parser.php
@@ -20,7 +20,7 @@
* Additions and fixes Copyright (c) 2010-17 Netcarver https://github.com/netcarver
* Additions and fixes Copyright (c) 2011 Jeff Soo http://ipsedixit.net/
* Additions and fixes Copyright (c) 2012 Robert Wetzlmayr http://wetzlmayr.com/
- * Additions and fixes Copyright (c) 2012-19 Jukka Svahn http://rahforum.biz/
+ * Additions and fixes Copyright (c) 2012-24 Jukka Svahn https://rahforum.biz/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -365,12 +365,26 @@
class Parser
{
+ /**
+ * HTML5 document type.
+ *
+ * @since 3.8.0
+ */
+ const DOCTYPE_HTML5 = 'html5';
+
+ /**
+ * XHTML document type.
+ *
+ * @since 3.8.0
+ */
+ const DOCTYPE_XHTML = 'xhtml';
+
/**
* Version number.
*
* @var string
*/
- protected $ver = '3.7.7';
+ protected $ver = '4.1.2';
/**
* Regular expression snippets.
@@ -623,6 +637,13 @@ class Parser
*/
protected $lineWrapEnabled = true;
+ /**
+ * Whether aligning with class selectors is enabled.
+ *
+ * @var bool|null
+ */
+ protected $isAlignClassesEnabled = null;
+
/**
* Pattern for punctation.
*
@@ -843,8 +864,8 @@ class Parser
* @since 3.6.0
*/
protected $doctypes = array(
- 'xhtml',
- 'html5',
+ self::DOCTYPE_XHTML,
+ self::DOCTYPE_HTML5,
);
/**
@@ -1031,7 +1052,8 @@ class Parser
* a whole, such as the output doctype. To instruct the parser to return
* HTML5 markup instead of XHTML, set $doctype argument to 'html5'.
*
- * bc. $parser = new \Netcarver\Textile\Parser('html5');
+ * bc. use Netcarver\Textile\Parser;
+ * $parser = new Parser(Parser::DOCTYPE_HTML5);
* echo $parser->parse('HTML(HyperText Markup Language)");
*
* @param string $doctype The output document type, either 'xhtml' or 'html5'
@@ -1039,6 +1061,8 @@ class Parser
* @see Parser::configure()
* @see Parser::parse()
* @see Parser::setDocumentType()
+ * @see Parser::DOCTYPE_HTML5
+ * @see Parser::DOCTYPE_XHTML
* @api
*/
public function __construct($doctype = 'xhtml')
@@ -1137,15 +1161,18 @@ protected function configure()
/**
* Sets the output document type.
*
- * bc. $parser = new \Netcarver\Textile\Parser();
+ * bc. use Netcarver\Textile\Parser;
+ * $parser = new Parser();
* echo $parser
- * ->setDocumentType('html5')
+ * ->setDocumentType(Parser::DOCTYPE_HTML5)
* ->parse('HTML(HyperText Markup Language)");
*
* @param string $doctype Either 'xhtml' or 'html5'
* @return Parser This instance
* @since 3.6.0
* @see Parser::getDocumentType()
+ * @see Parser::DOCTYPE_HTML5
+ * @see Parser::DOCTYPE_XHTML
* @api
*/
public function setDocumentType($doctype)
@@ -1477,6 +1504,59 @@ public function isRawBlocksEnabled()
return (bool) $this->rawBlocksEnabled;
}
+ /**
+ * Sets class alignment mode independent of the document type.
+ *
+ * In HTML5 document type, img elements are generated with align-left,
+ * align-center and align-right class selectors rather than align
+ * attribute being added to the image.
+ *
+ * With this option you can enable that functionality in XHTML document type mode too.
+ *
+ * bc. $parser = new \Netcarver\Textile\Parser();
+ * $parser
+ * ->setAlignClasses(true)
+ * ->parse(!
+ *
+ * @param bool $enabled TRUE to enable, FALSE to disable
+ * @return Parser This instance
+ * @since 3.8.0
+ * @api
+ */
+ public function setAlignClasses($enabled)
+ {
+ $this->isAlignClassesEnabled = (bool) $enabled;
+ return $this;
+ }
+
+ /**
+ * Whether class alignment mode is enabled.
+ *
+ * bc. $parser = new \Netcarver\Textile\Parser();
+ * if ($parser->isAlignClassesEnabled() === true) {
+ * echo 'Images are aligned with class instead of align attribute';
+ * }
+ *
+ * @return bool TRUE if enabled, FALSE otherwise
+ * @since 3.8.0
+ * @see Parser::setAlignClasses()
+ * @api
+ */
+ public function isAlignClassesEnabled()
+ {
+ if ($this->isAlignClassesEnabled === null
+ && $this->getDocumentType() === self::DOCTYPE_HTML5
+ ) {
+ return true;
+ }
+
+ return (bool) $this->isAlignClassesEnabled;
+ }
+
/**
* Enables and disables block-level tags and formatting features.
*
@@ -1892,6 +1972,9 @@ public function parse($text)
// Inline markup (em, strong, sup, sub, del etc).
$text = $this->spans($text);
+ // Generate links.
+ $text = $this->links($text);
+
// Glyph level substitutions (mainly typographic -- " & ' => curly quotes, -- => em-dash etc.
$text = $this->glyphs($text);
}
@@ -1901,7 +1984,10 @@ public function parse($text)
$text = $this->retrieveTags($text);
$text = $this->retrieveURLs($text);
- $text = str_replace("
", "
\n", $text);
+ // Replace shelved instances that were inside tag and link attributes.
+ $text = $this->retrieve($text);
+
+ $text = str_replace($this->getLineBreak(), $this->getLineBreak()."\n", $text);
return $text;
}
@@ -1910,12 +1996,12 @@ public function parse($text)
* Parses the given Textile input in un-restricted mode.
*
* This method is deprecated, use Parser::parse() method instead.
- * This method is equilavent of:
+ * This method is equivalent of:
*
* bc. $parser = new \Netcarver\Textile\Parser();
* echo $parser->parse('h1. Hello World!');
*
- * Additinal arguments can be passed with setter methods:
+ * Additional arguments can be passed with setter methods:
*
* bc. $parser = new \Netcarver\Textile\Parser();
* echo $parser
@@ -2025,6 +2111,18 @@ protected function textileCommon($text, $lite)
return $this->setLite($lite)->parse($text);
}
+ /**
+ * Output line break according to document type.
+ *
+ * @return string The break tag
+ * @since 4.0.0
+ * @see Parser::getDocumentType()
+ */
+ protected function getLineBreak()
+ {
+ return ($this->getDocumentType() === self::DOCTYPE_HTML5) ? '
' : '
';
+ }
+
/**
* Prepares the glyph patterns from the symbol table.
*
@@ -2300,7 +2398,7 @@ protected function prepare($lite = null, $noimage = null, $rel = null)
* Cleans a HTML attribute value.
*
* This method checks for presence of URL encoding in the value.
- * If the number encoded characters exceeds the thereshold,
+ * If the number encoded characters exceeds the threshold,
* the input is discarded. Otherwise the encoded
* instances are decoded.
*
@@ -2344,12 +2442,12 @@ protected function cleanAttribs($in)
*
* @param string $name The HTML element name
* @param array $atts HTML attributes applied to the tag
- * @param bool $selfclosing Determines if the tag should be selfclosing
+ * @param bool $selfclosing Determines if the tag should be self-closing
* @return Tag
*/
protected function newTag($name, $atts, $selfclosing = true)
{
- return new Tag($name, $atts, $selfclosing);
+ return new Tag($name, $atts, $selfclosing && $this->getDocumentType() !== self::DOCTYPE_HTML5);
}
/**
@@ -2420,10 +2518,10 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
}
}
- if ($element == 'td' or $element == 'tr') {
- if (preg_match("/^($this->vlgn)/", $matched, $vert)) {
- $style[] = "vertical-align:" . $this->vAlign($vert[1]);
- }
+ if (($element === 'td' || $element === 'tr')
+ && preg_match("/^($this->vlgn)/", $matched, $vert)
+ ) {
+ $style[] = "vertical-align:" . $this->vAlign($vert[1]);
}
if (preg_match("/\{([^}]*)\}/", $matched, $sty)) {
@@ -2434,25 +2532,15 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
$matched = str_replace($sty[0], '', $matched);
}
- if (preg_match("/\[([^]]+)\]/U", $matched, $lng)) {
- // Consume entire lang block -- valid or invalid.
- $matched = str_replace($lng[0], '', $matched);
- if ($element === 'code' && preg_match("/\[([a-zA-Z0-9_-]+)\]/U", $lng[0], $lng1)) {
- $lang = $lng1[1];
- } elseif (preg_match("/\[([a-zA-Z]{2}(?:[\-\_][a-zA-Z]{2})?)\]/U", $lng[0], $lng2)) {
- $lang = $lng2[1];
- }
- }
-
if (preg_match("/\(([^()]+)\)/U", $matched, $cls)) {
- $class_regex = "/^([-a-zA-Z 0-9_\.]*)$/";
+ $class_regex = "/^([-a-zA-Z 0-9_\.\/\[\]:!]*)$/";
// Consume entire class block -- valid or invalid.
$matched = str_replace($cls[0], '', $matched);
// Only allow a restricted subset of the CSS standard characters for classes/ids.
// No encoding markers allowed.
- if (preg_match("/\(([-a-zA-Z 0-9_\.\:\#]+)\)/U", $cls[0], $cls)) {
+ if (preg_match("/\(([-a-zA-Z 0-9_\/\[\].:!#]+)\)/U", $cls[0], $cls)) {
$hashpos = strpos($cls[1], '#');
// If a textile class block attribute was found with a '#' in it
// split it into the css class and css id...
@@ -2472,12 +2560,22 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
}
}
- if (preg_match("/([(]+)/", $matched, $pl)) {
+ if (preg_match("/\[([^]]+)\]/U", $matched, $lng)) {
+ // Consume entire lang block -- valid or invalid.
+ $matched = str_replace($lng[0], '', $matched);
+ if ($element === 'code' && preg_match("/\[([a-zA-Z0-9_-]+)\]/U", $lng[0], $lng1)) {
+ $lang = $lng1[1];
+ } elseif (preg_match("/\[([a-zA-Z]{2}(?:[\-\_][a-zA-Z]{2})?)\]/U", $lng[0], $lng2)) {
+ $lang = $lng2[1];
+ }
+ }
+
+ if (preg_match("/(\(+)/", $matched, $pl)) {
$style[] = "padding-left:" . strlen($pl[1]) . "em";
$matched = str_replace($pl[0], '', $matched);
}
- if (preg_match("/([)]+)/", $matched, $pr)) {
+ if (preg_match("/(\)+)/", $matched, $pr)) {
$style[] = "padding-right:" . strlen($pr[1]) . "em";
$matched = str_replace($pr[0], '', $matched);
}
@@ -2486,11 +2584,11 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
$style[] = "text-align:" . $this->hAlign($horiz[1]);
}
- if ($element == 'col') {
- if (preg_match("/(?:\\\\([0-9]+))?{$this->regex_snippets['space']}*([0-9]+)?/", $matched, $csp)) {
- $span = isset($csp[1]) ? $csp[1] : '';
- $width = isset($csp[2]) ? $csp[2] : '';
- }
+ if ($element == 'col'
+ && preg_match("/(?:\\\\([0-9]+))?{$this->regex_snippets['space']}*([0-9]+)?/", $matched, $csp)
+ ) {
+ $span = isset($csp[1]) ? $csp[1] : '';
+ $width = isset($csp[2]) ? $csp[2] : '';
}
if ($this->isRestrictedModeEnabled()) {
@@ -2814,7 +2912,7 @@ protected function fRedclothList($m)
$out = array();
/** @var array $text */
- $text = preg_split('/\n(?=[-])/m', $in);
+ $text = preg_split('/\n(?=-)/m', $in);
foreach ($text as $line) {
$m = array();
@@ -2850,7 +2948,7 @@ protected function fRedclothList($m)
$def = trim($def);
if ($this->isLineWrapEnabled()) {
- $def = str_replace("\n", "
", $def);
+ $def = str_replace("\n", $this->getLineBreak(), $def);
}
if ($pos === 0) {
@@ -2858,7 +2956,7 @@ protected function fRedclothList($m)
}
if ($this->isLineWrapEnabled()) {
- $term = str_replace("\n", "
", $term);
+ $term = str_replace("\n", $this->getLineBreak(), $term);
}
$term = $this->graf($term);
@@ -2941,8 +3039,8 @@ protected function fTextileList($m)
foreach ($list as $index => $m) {
$start = '';
- $content = trim($m['content']);
- $ltype = $this->liType($m['tl']);
+ $content = trim((string) $m['content']);
+ $ltype = $this->liType((string) $m['tl']);
if (isset($list[$index + 1])) {
$next = $list[$index + 1];
@@ -2950,9 +3048,9 @@ protected function fTextileList($m)
$next = false;
}
- if (strpos($m['tl'], ';') !== false) {
+ if (strpos((string) $m['tl'], ';') !== false) {
$litem = 'dt';
- } elseif (strpos($m['tl'], ':') !== false) {
+ } elseif (strpos((string) $m['tl'], ':') !== false) {
$litem = 'dd';
} else {
$litem = 'li';
@@ -2982,12 +3080,16 @@ protected function fTextileList($m)
}
}
- if ($prev && $prev['tl'] && strpos($prev['tl'], ';') !== false && strpos($m['tl'], ':') !== false) {
+ if ($prev
+ && $prev['tl']
+ && strpos((string) $prev['tl'], ';') !== false
+ && strpos((string) $m['tl'], ':') !== false
+ ) {
$lists[$m['tl']] = 2;
}
- $tabs = str_repeat("\t", $m['level'] - 1);
- $atts = $this->parseAttribs($m['atts']);
+ $tabs = str_repeat("\t", ((int) $m['level']) - 1);
+ $atts = $this->parseAttribs((string) $m['atts']);
if (!isset($lists[$m['tl']])) {
$lists[$m['tl']] = 1;
@@ -3102,7 +3204,7 @@ protected function fPBr($m)
// Replaces those LFs that aren't followed by white-space, or at end, with
or a space.
$m['content'] = preg_replace(
"/\n(?![\s|])/",
- $this->isLineWrapEnabled() ? '
' : ' ',
+ $this->isLineWrapEnabled() ? $this->getLineBreak() : ' ',
(string) $m['content']
);
@@ -3119,7 +3221,7 @@ protected function fBr($m)
{
$content = preg_replace(
"@(.+)(?|
|||)\n(?![\s|])@",
- $this->isLineWrapEnabled() ? '$1
' : '$1 ',
+ $this->isLineWrapEnabled() ? '$1'.$this->getLineBreak() : '$1 ',
$m['content']
);
@@ -3222,8 +3324,10 @@ protected function blocks($text)
}
}
- $block = $this->doPBr((string) $block);
- $block = $whitespace. str_replace('
', '
', $block);
+ $block = $whitespace . $this->doPBr((string) $block);
+ if ($this->getDocumentType() === self::DOCTYPE_XHTML) {
+ $block = str_replace('
', '
', $block);
+ }
// @phpstan-ignore-next-line
if ($ext && $anonymous_block) {
@@ -3660,7 +3764,6 @@ protected function placeNoteLists($text)
ksort($o);
}
- // @phpstan-ignore-next-line
$this->notes = $o;
}
@@ -3855,6 +3958,7 @@ protected function fParseNoteRefs($m)
// If we are referencing a note that hasn't had the definition parsed yet, then assign it an ID.
if (empty($this->notes[$m['label']]['id'])) {
+ // @phpstan-ignore-next-line
$id = $this->notes[$m['label']]['id'] = $this->linkPrefix . ($this->linkIndex++);
} else {
$id = $this->notes[$m['label']]['id'];
@@ -3864,6 +3968,7 @@ protected function fParseNoteRefs($m)
$out = ''.$num.'';
if (!$nolink) {
+ // @phpstan-ignore-next-line
$out = ''.$out.'';
}
@@ -4139,7 +4244,7 @@ protected function fLink($m)
$in = $m[0];
$pre = $m['pre'];
if ($this->isLineWrapEnabled()) {
- $inner = str_replace("\n", '
', $m['inner']);
+ $inner = str_replace("\n", $this->getLineBreak(), $m['inner']);
} else {
$inner = str_replace("\n", ' ', $m['inner']);
}
@@ -4185,12 +4290,12 @@ protected function fLink($m)
// eg. "text":url][otherstuff... will have "[otherstuff" popped back out.
// "text":url?q[]=x][123] will have "[123]" popped off the back, the remaining closing square brackets
// will later be tested for balance
- if ($counts[']']) {
- if (1 === preg_match('@(?P^.*\])(?P\[.*?)$@' . $this->regex_snippets['mod'], $url, $m)) {
- $url = $m['url'];
- $tight = $m['tight'];
- $m = array();
- }
+ if ($counts[']']
+ && 1 === preg_match('@(?P^.*\])(?P\[.*?)$@' . $this->regex_snippets['mod'], $url, $m)
+ ) {
+ $url = $m['url'];
+ $tight = $m['tight'];
+ $m = array();
}
// Split off any trailing text that isn't part of an array assignment.
@@ -4198,12 +4303,12 @@ protected function fLink($m)
// "text":...?q[]=value1]following ... would have "following"
// popped back out and the remaining square bracket
// will later be tested for balance
- if ($counts[']']) {
- if (1 === preg_match('@(?P^.*\])(?!=)(?P.*?)$@' . $this->regex_snippets['mod'], $url, $m)) {
- $url = $m['url'];
- $tight = $m['end'] . $tight;
- $m = array();
- }
+ if ($counts[']']
+ && 1 === preg_match('@(?P^.*\])(?!=)(?P.*?)$@' . $this->regex_snippets['mod'], $url, $m)
+ ) {
+ $url = $m['url'];
+ $tight = $m['end'] . $tight;
+ $m = array();
}
// Does this need to be mb_ enabled? We are only searching for text in the ASCII charset anyway
@@ -4623,7 +4728,7 @@ protected function fImage($m)
);
if (isset($alignments[$align])) {
- if ($this->getDocumentType() === 'html5') {
+ if ($this->isAlignClassesEnabled()) {
$extras = 'align-'.$alignments[$align];
$align = '';
} else {
diff --git a/vendor/netcarver/textile/src/Netcarver/Textile/Tag.php b/vendor/netcarver/textile/src/Netcarver/Textile/Tag.php
index 421564d..3233c44 100644
--- a/vendor/netcarver/textile/src/Netcarver/Textile/Tag.php
+++ b/vendor/netcarver/textile/src/Netcarver/Textile/Tag.php
@@ -83,7 +83,7 @@ class Tag extends DataBag
* @param array $attributes An array of attributes
* @param bool $selfclosing Whether the tag is self-closing
*/
- public function __construct($name, array $attributes = null, $selfclosing = true)
+ public function __construct($name, $attributes = null, $selfclosing = true)
{
parent::__construct($attributes);
$this->tag = $name;
@@ -111,7 +111,7 @@ public function __toString()
}
if ($this->tag) {
- return '<' . $this->tag . $attributes . (($this->selfclose) ? " />" : '>');
+ return '<' . $this->tag . $attributes . (($this->selfclose) ? ' />' : '>');
}
return $attributes;