Skip to content

Commit

Permalink
Backport PHP >=7.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
gocom committed Nov 18, 2018
1 parent 0b51c20 commit 5d4ace9
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/test export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpcs.xml export-ignore
/phpunit.xml export-ignore
/.gitattributes export-ignore
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
language: php
php:
- 5.5
- 5.4
- 7.2
- 7.1
- 7.0
- 5.6
- hhvm

before_script:
- composer install

script:
- ./vendor/bin/phpcs --standard=PSR1,PSR2 src test
- ./vendor/bin/phpcs
- ./vendor/bin/phpunit

after_script:
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ 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 3.5.6 - upcoming
h2. "Version 3.5.6 - 2018/11/18":https://github.com/textile/php-textile/releases/tag/v3.5.6

* Fix PHP >=7.2 compatibility.

h2. "Version 3.5.5 - 2014/01/02":https://github.com/textile/php-textile/releases/tag/v3.5.5

Expand All @@ -22,7 +24,7 @@ h2. "Version 3.5.5 - 2014/01/02":https://github.com/textile/php-textile/releases
h2. "Version 3.5.4 - 2013/11/06":https://github.com/textile/php-textile/releases/tag/v3.5.4

* Fix broken image alignment in HTML5 mode (closes "#123":https://github.com/textile/php-textile/issues/123).
* Fix duplicate HTML IDs that occur when a footnote isn't referenced in the content (closes "#125":https://github.com/textile/php-textile/issues/125).
* Fix duplicate HTML IDs that occur when a footnote isn't referenced in the content (closes "#125":https://github.com/textile/php-textile/issues/125).
* Don't include image alignment to the URL in restricted mode.
* Detect and process quoted quote symbols.
* New link parser (closes "#86":https://github.com/textile/php-textile/issues/86, "#87":https://github.com/textile/php-textile/issues/87 and "#128":https://github.com/textile/php-textile/issues/128).
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Additions and fixes Copyright (c) 2010 Stef Dawson http://stefdawson.co
Additions and fixes Copyright (c) 2010-13 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-13 Jukka Svahn http://rahforum.biz/
Additions and fixes Copyright (c) 2012-18 Jukka Svahn http://rahforum.biz/

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ h1. PHP-Textile

"Downloads":https://github.com/textile/php-textile/releases | "Textile reference":http://txstyle.org/article/43/a-short-introduction | "Live editor":http://txstyle.org/ | "Packagist":https://packagist.org/packages/netcarver/textile

!https://travis-ci.org/textile/php-textile.png?branch=master!:https://travis-ci.org/textile/php-textile !https://coveralls.io/repos/textile/php-textile/badge.png?branch=master!:https://coveralls.io/r/textile/php-textile?branch=master
!https://travis-ci.org/textile/php-textile.png?branch=3.5!:https://travis-ci.org/textile/php-textile !https://coveralls.io/repos/textile/php-textile/badge.png?branch=3.5!:https://coveralls.io/r/textile/php-textile?branch=3.5

PHP-Textile is a modern Textile markup language parser for PHP. Textile is a humane web text generator that takes lightweight, readable, plaintext-like markup language and converts it into well formed HTML.

Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@
"source": "https://github.com/textile/php-textile"
},
"autoload": {
"psr-0": { "Netcarver\\Textile": "src/" }
"psr-4": {
"Netcarver\\Textile\\": "src/Netcarver/Textile/"
}
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"symfony/yaml": "2.3.*",
"squizlabs/php_codesniffer": "1.5.*",
"phpunit/phpunit": "5.7.*",
"symfony/yaml": "2.4.*",
"squizlabs/php_codesniffer": "3.*",
"satooshi/php-coveralls": "0.6.*"
},
"scripts": {
"test": "./vendor/bin/phpunit",
"cs": "./vendor/bin/phpcs"
}
}
7 changes: 7 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer">
<file>src</file>
<file>test</file>
<rule ref="PSR1"/>
<rule ref="PSR2"/>
</ruleset>
5 changes: 5 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<directory>./test/Netcarver/Textile/Test/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
Expand Down
19 changes: 5 additions & 14 deletions src/Netcarver/Textile/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Additions and fixes Copyright (c) 2010-13 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-13 Jukka Svahn http://rahforum.biz/
* Additions and fixes Copyright (c) 2012-18 Jukka Svahn http://rahforum.biz/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -350,7 +350,7 @@ class Parser
* @var string
*/

protected $ver = '3.5.5';
protected $ver = '3.5.6';

/**
* Regular expression snippets.
Expand Down Expand Up @@ -1508,7 +1508,7 @@ protected function formatAttributeString(array $attribute_array)

protected function parseAttribsToArray($in, $element = '', $include_id = true, $autoclass = '')
{
$style = '';
$style = array();
$class = '';
$lang = '';
$colspan = '';
Expand Down Expand Up @@ -1552,7 +1552,6 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
}

if (preg_match("/\(([^()]+)\)/U", $matched, $cls)) {

$class_regex = "/^([-a-zA-Z 0-9_\.]*)$/";

// Consume entire class block -- valid or invalid.
Expand Down Expand Up @@ -1643,7 +1642,7 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
$o['span'] = $this->cleanAttribs($span);
}

if ($style) {
if (!empty($style)) {
$so = '';
$tmps = array();
foreach ($style as $s) {
Expand All @@ -1661,9 +1660,8 @@ protected function parseAttribsToArray($in, $element = '', $include_id = true, $
$so .= $p.';';
}
}
$style = trim(str_replace(array("\n", ';;'), array('', ';'), $so));

$o['style'] = $style;
$o['style'] = trim(str_replace(array("\n", ';;'), array('', ';'), $so));
}

if ($width) {
Expand Down Expand Up @@ -1735,7 +1733,6 @@ protected function fTable($matches)
$c_row = 1;

foreach (preg_split("/\|{$space}*?$/m", $matches['rows'], -1, PREG_SPLIT_NO_EMPTY) as $row) {

$row = ltrim($row);

// Caption -- can only occur on row 1, otherwise treat '|=. foo |...'
Expand Down Expand Up @@ -2186,7 +2183,6 @@ protected function blocks($text)
$out = array();

foreach ($textblocks as $block) {

// Line is just whitespace, keep it for the next block.
if (trim($block) === '') {
if ($eatWhitespace === false) {
Expand Down Expand Up @@ -2257,7 +2253,6 @@ protected function blocks($text)
} else {
$whitespace = '';
}

}

if ($ext) {
Expand Down Expand Up @@ -3003,13 +2998,11 @@ protected function markStartOfLinks($text)
$slices = preg_split('/":(?='.$this->regex_snippets['char'].')/'.$mod, $text);

if (count($slices) > 1) {

// There are never any start of links in the last slice, so pop it
// off (we'll glue it back later).
$last_slice = array_pop($slices);

foreach ($slices as &$slice) {

// If there is no possible start quote then this slice is not a link
if (false === strpos($slice, '"')) {
continue;
Expand Down Expand Up @@ -3078,7 +3071,6 @@ protected function markStartOfLinks($text)
array_push($possible_start_quotes, $possibility);
break;
}

}

// Rebuild the link's text by reversing the parts and sticking them back
Expand Down Expand Up @@ -3221,7 +3213,6 @@ protected function fLink($m)
$c = array_pop($url_chars);
$popped = false;
switch ($c) {

// Textile URL shouldn't end in these characters, we pop
// them off the end and push them out the back of the url again.
case '!':
Expand Down

0 comments on commit 5d4ace9

Please sign in to comment.