Merge pull request #4244 from MrPetovan/develop

Composer: php-markdown updated to 1.8.0
This commit is contained in:
Michael Vogel 2018-01-15 14:58:38 +01:00 committed by GitHub
commit cc3b6a265c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 409 additions and 368 deletions

19
composer.lock generated
View file

@ -161,30 +161,25 @@
},
{
"name": "michelf/php-markdown",
"version": "1.7.0",
"version": "1.8.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220"
"reference": "01ab082b355bf188d907b9929cd99b2923053495"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/1f51cc520948f66cd2af8cbc45a5ee175e774220",
"reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/01ab082b355bf188d907b9929cd99b2923053495",
"reference": "01ab082b355bf188d907b9929cd99b2923053495",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
},
"autoload": {
"psr-0": {
"Michelf": ""
"psr-4": {
"Michelf\\": "Michelf/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -208,7 +203,7 @@
"keywords": [
"markdown"
],
"time": "2016-10-29T18:58:20+00:00"
"time": "2018-01-15T00:49:33+00:00"
},
{
"name": "mobiledetect/mobiledetectlib",

View file

@ -17,6 +17,7 @@ return array(
'Friendica\\Content\\ForumManager' => $baseDir . '/src/Content/ForumManager.php',
'Friendica\\Content\\OEmbed' => $baseDir . '/src/Content/OEmbed.php',
'Friendica\\Content\\Smilies' => $baseDir . '/src/Content/Smilies.php',
'Friendica\\Content\\Text\\Markdown' => $baseDir . '/src/Content/Text/Markdown.php',
'Friendica\\Core\\Cache' => $baseDir . '/src/Core/Cache.php',
'Friendica\\Core\\Config' => $baseDir . '/src/Core/Config.php',
'Friendica\\Core\\NotificationsManager' => $baseDir . '/src/Core/NotificationsManager.php',

View file

@ -7,7 +7,6 @@ $baseDir = dirname($vendorDir);
return array(
'Text' => array($vendorDir . '/pear/text_languagedetect'),
'Michelf' => array($vendorDir . '/michelf/php-markdown'),
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
'Detection' => array($vendorDir . '/mobiledetect/mobiledetectlib/namespaced'),
);

View file

@ -6,6 +6,7 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Michelf\\' => array($vendorDir . '/michelf/php-markdown/Michelf'),
'League\\HTMLToMarkdown\\' => array($vendorDir . '/league/html-to-markdown/src'),
'Friendica\\' => array($baseDir . '/src'),
);

View file

@ -14,6 +14,10 @@ class ComposerStaticInitFriendica
);
public static $prefixLengthsPsr4 = array (
'M' =>
array (
'Michelf\\' => 8,
),
'L' =>
array (
'League\\HTMLToMarkdown\\' => 22,
@ -25,6 +29,10 @@ class ComposerStaticInitFriendica
);
public static $prefixDirsPsr4 = array (
'Michelf\\' =>
array (
0 => __DIR__ . '/..' . '/michelf/php-markdown/Michelf',
),
'League\\HTMLToMarkdown\\' =>
array (
0 => __DIR__ . '/..' . '/league/html-to-markdown/src',
@ -43,13 +51,6 @@ class ComposerStaticInitFriendica
0 => __DIR__ . '/..' . '/pear/text_languagedetect',
),
),
'M' =>
array (
'Michelf' =>
array (
0 => __DIR__ . '/..' . '/michelf/php-markdown',
),
),
'H' =>
array (
'HTMLPurifier' =>
@ -78,6 +79,7 @@ class ComposerStaticInitFriendica
'Friendica\\Content\\ForumManager' => __DIR__ . '/../..' . '/src/Content/ForumManager.php',
'Friendica\\Content\\OEmbed' => __DIR__ . '/../..' . '/src/Content/OEmbed.php',
'Friendica\\Content\\Smilies' => __DIR__ . '/../..' . '/src/Content/Smilies.php',
'Friendica\\Content\\Text\\Markdown' => __DIR__ . '/../..' . '/src/Content/Text/Markdown.php',
'Friendica\\Core\\Cache' => __DIR__ . '/../..' . '/src/Core/Cache.php',
'Friendica\\Core\\Config' => __DIR__ . '/../..' . '/src/Core/Config.php',
'Friendica\\Core\\NotificationsManager' => __DIR__ . '/../..' . '/src/Core/NotificationsManager.php',

View file

@ -160,33 +160,28 @@
},
{
"name": "michelf/php-markdown",
"version": "1.7.0",
"version_normalized": "1.7.0.0",
"version": "1.8.0",
"version_normalized": "1.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/michelf/php-markdown.git",
"reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220"
"reference": "01ab082b355bf188d907b9929cd99b2923053495"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/1f51cc520948f66cd2af8cbc45a5ee175e774220",
"reference": "1f51cc520948f66cd2af8cbc45a5ee175e774220",
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/01ab082b355bf188d907b9929cd99b2923053495",
"reference": "01ab082b355bf188d907b9929cd99b2923053495",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2016-10-29T18:58:20+00:00",
"time": "2018-01-15T00:49:33+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Michelf": ""
"psr-4": {
"Michelf\\": "Michelf/"
}
},
"notification-url": "https://packagist.org/downloads/",

View file

@ -0,0 +1,3 @@
*~
/composer.lock
/vendor/

View file

@ -1,5 +1,5 @@
PHP Markdown Lib
Copyright (c) 2004-2016 Michel Fortin
Copyright (c) 2004-2018 Michel Fortin
<https://michelf.ca/>
All rights reserved.

View file

@ -4,7 +4,7 @@
*
* @package php-markdown
* @author Michel Fortin <michel.fortin@michelf.com>
* @copyright 2004-2016 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright 2004-2018 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
*/
@ -18,7 +18,7 @@ class Markdown implements MarkdownInterface {
* Define the package version
* @var string
*/
const MARKDOWNLIB_VERSION = "1.7.0";
const MARKDOWNLIB_VERSION = "1.8.0";
/**
* Simple function interface - Initialize the parser and return the result
@ -187,6 +187,12 @@ class Markdown implements MarkdownInterface {
*/
protected $in_anchor = false;
/**
* Status flag to avoid invalid nesting.
* @var boolean
*/
protected $in_emphasis_processing = false;
/**
* Called before the transformation process starts to setup parser states.
* @return void
@ -197,6 +203,7 @@ class Markdown implements MarkdownInterface {
$this->titles = $this->predef_titles;
$this->html_hashes = array();
$this->in_anchor = false;
$this->in_emphasis_processing = false;
}
/**
@ -1303,6 +1310,11 @@ class Markdown implements MarkdownInterface {
* @return string
*/
protected function doItalicsAndBold($text) {
if ($this->in_emphasis_processing) {
return $text; // avoid reentrency
}
$this->in_emphasis_processing = true;
$token_stack = array('');
$text_stack = array('');
$em = '';
@ -1383,6 +1395,7 @@ class Markdown implements MarkdownInterface {
if (strlen($token_stack[0]) == 1) {
$text_stack[1] .= array_shift($token_stack);
$text_stack[0] .= array_shift($text_stack);
$em = '';
}
// Closing strong marker:
array_shift($token_stack);
@ -1417,6 +1430,7 @@ class Markdown implements MarkdownInterface {
}
}
}
$this->in_emphasis_processing = false;
return $text_stack[0];
}
@ -1870,9 +1884,9 @@ class Markdown implements MarkdownInterface {
return;
}
$this->utf8_strlen = create_function('$text', 'return preg_match_all(
"/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/",
$text, $m);');
$this->utf8_strlen = function($text) {
return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
};
}
/**

View file

@ -4,7 +4,7 @@
*
* @package php-markdown
* @author Michel Fortin <michel.fortin@michelf.com>
* @copyright 2004-2016 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright 2004-2018 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
*/
@ -73,6 +73,12 @@ class MarkdownExtra extends \Michelf\Markdown {
*/
public $predef_abbr = array();
/**
* Only convert atx-style headers if there's a space between the header and #
* @var boolean
*/
public $hashtag_protection = false;
/**
* Parser implementation
*/
@ -118,7 +124,7 @@ class MarkdownExtra extends \Michelf\Markdown {
protected $footnotes_ref_count = array();
protected $footnotes_numbers = array();
protected $abbr_desciptions = array();
/** @var @string */
/** @var string */
protected $abbr_word_re = '';
/**
@ -1042,7 +1048,7 @@ class MarkdownExtra extends \Michelf\Markdown {
//
$text = preg_replace_callback('{
^(\#{1,6}) # $1 = string of #\'s
[ ]*
[ ]'.($this->hashtag_protection ? '+' : '*').'
(.+?) # $2 = Header text
[ ]*
\#* # optional closing #\'s (not counted)
@ -1604,7 +1610,7 @@ class MarkdownExtra extends \Michelf\Markdown {
if (!empty($this->footnotes_ordered)) {
$text .= "\n\n";
$text .= "<div class=\"footnotes\">\n";
$text .= "<div class=\"footnotes\" role=\"doc-endnotes\">\n";
$text .= "<hr" . $this->empty_element_suffix . "\n";
$text .= "<ol>\n\n";
@ -1618,7 +1624,9 @@ class MarkdownExtra extends \Michelf\Markdown {
$title = $this->fn_backlink_title;
$title = $this->encodeAttribute($title);
$attr .= " title=\"$title\"";
$attr .= " aria-label=\"$title\"";
}
$attr .= " role=\"doc-backlink\"";
$backlink_text = $this->fn_backlink_html;
$num = 0;
@ -1650,7 +1658,7 @@ class MarkdownExtra extends \Michelf\Markdown {
$footnote .= "\n\n<p>$backlink</p>";
}
$text .= "<li id=\"fn:$note_id\">\n";
$text .= "<li id=\"fn:$note_id\" role=\"doc-endnote\">\n";
$text .= $footnote . "\n";
$text .= "</li>\n\n";
}
@ -1695,6 +1703,7 @@ class MarkdownExtra extends \Michelf\Markdown {
$title = $this->encodeAttribute($title);
$attr .= " title=\"$title\"";
}
$attr .= " role=\"doc-noteref\"";
$attr = str_replace("%%", $num, $attr);
$node_id = $this->encodeAttribute($node_id);

View file

@ -4,7 +4,7 @@
*
* @package php-markdown
* @author Michel Fortin <michel.fortin@michelf.com>
* @copyright 2004-2016 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright 2004-2018 Michel Fortin <https://michelf.com/projects/php-markdown/>
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
*/

View file

@ -1,7 +1,7 @@
PHP Markdown
============
PHP Markdown Lib 1.7.0 - 29 Oct 2016
PHP Markdown Lib 1.8.0 - 14 Jan 2018
by Michel Fortin
<https://michelf.ca/>
@ -37,7 +37,8 @@ Requirement
This library package requires PHP 5.3 or later.
Note: The older plugin/library hybrid package for PHP Markdown and
PHP Markdown Extra is still maintained and will work with PHP 4.0.5 and later.
PHP Markdown Extra is no longer maintained but will work with PHP 4.0.5 and
later.
Before PHP 5.3.7, pcre.backtrack_limit defaults to 100 000, which is too small
in many situations. You might need to set it to higher values. Later PHP
@ -47,27 +48,33 @@ releases defaults to 1 000 000, which is usually fine.
Usage
-----
This library package is meant to be used with class autoloading. For autoloading
to work, your project needs have setup a PSR-0-compatible autoloader. See the
included Readme.php file for a minimal autoloader setup. (If you cannot use
autoloading, see below.)
To use this library with Composer, first install it with:
With class autoloading in place, putting the 'Michelf' folder in your
include path should be enough for this to work:
$ composer require michelf/php-markdown
use \Michelf\Markdown;
Then include Composer's generated vendor/autoload.php to [enable autoloading]:
require 'vendor/autoload.php';
Without Composer, for autoloading to work, your project needs an autoloader
compatible with PSR-4 or PSR-0. See the included Readme.php file for a minimal
autoloader setup. (If you cannot use autoloading, see below.)
With class autoloading in place:
use Michelf\Markdown;
$my_html = Markdown::defaultTransform($my_text);
Markdown Extra syntax is also available the same way:
use \Michelf\MarkdownExtra;
use Michelf\MarkdownExtra;
$my_html = MarkdownExtra::defaultTransform($my_text);
If you wish to use PHP Markdown with another text filter function
built to parse HTML, you should filter the text *after* the `transform`
function call. This is an example with [PHP SmartyPants][psp]:
function call. This is an example with [PHP SmartyPants]:
use \Michelf\Markdown, \Michelf\SmartyPants;
use Michelf\Markdown, Michelf\SmartyPants;
$my_html = Markdown::defaultTransform($my_text);
$my_html = SmartyPants::defaultTransform($my_html);
@ -76,24 +83,26 @@ found inside the parser class. If you want to customize the parser
configuration, you can also instantiate it directly and change some
configuration variables:
use \Michelf\MarkdownExtra;
use Michelf\MarkdownExtra;
$parser = new MarkdownExtra;
$parser->fn_id_prefix = "post22-";
$my_html = $parser->transform($my_text);
To learn more, see the full list of [configuration variables].
[enable autoloading]: https://getcomposer.org/doc/01-basic-usage.md#autoloading
[PHP SmartyPants]: https://michelf.ca/projects/php-smartypants/
[configuration variables]: https://michelf.ca/projects/php-markdown/configuration/
### Usage without an autoloader
If you cannot use class autoloading, you can still use `include` or `require`
to access the parser. To load the `\Michelf\Markdown` parser, do it this way:
to access the parser. To load the `Michelf\Markdown` parser, do it this way:
require_once 'Michelf/Markdown.inc.php';
Or, if you need the `\Michelf\MarkdownExtra` parser:
Or, if you need the `Michelf\MarkdownExtra` parser:
require_once 'Michelf/MarkdownExtra.inc.php';
@ -174,6 +183,22 @@ PHP Markdown, please visit [michelf.ca/donate] or send Bitcoin to
Version History
---------------
PHP Markdown Lib 1.8.0 (14 Jan 2018)
* Autoloading with Composer now uses PSR-4.
* HTML output for Markdown Extra footnotes now include `role` attributes
with values from [WAI-ARIA](https://www.w3.org/TR/dpub-aria/) to
make them more accessible.
(Thanks to Tobias Bengfort)
* In Markdown Extra, added the `hashtag_protection` configuration variable.
When set to `true` it prevents ATX-style headers with no space after the initial
hash from being interpreted as headers. This way your precious hashtags
are preserved.
(Thanks to Jaussoin Timothée for the implementation.)
PHP Markdown Lib 1.7.0 (29 Oct 2016)
* Added a `hard_wrap` configuration variable to make all newline characters
@ -192,7 +217,7 @@ PHP Markdown Lib 1.7.0 (29 Oct 2016)
code block equivalent, there is no syntax for specifying a language.
Credits to styxit for the implementation.
* Fixed a Markdwon Extra issue where two-space-at-end-of-line hard breaks
* Fixed a Markdown Extra issue where two-space-at-end-of-line hard breaks
wouldn't work inside of HTML block elements such as `<p markdown="1">`
where the element expects only span-level content.

View file

@ -4,13 +4,15 @@
// through the Markdown filter. You can adapt this sample code in any way
// you like.
// Install PSR-0-compatible class autoloader
// Install PSR-4-compatible class autoloader
spl_autoload_register(function($class){
require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
require str_replace('\\', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
});
// If using Composer, use this instead:
//require 'vendor/autoloader.php';
// Get Markdown class
use \Michelf\Markdown;
use Michelf\Markdown;
// Read file and pass content through the Markdown parser
$text = file_get_contents('Readme.md');

View file

@ -21,11 +21,6 @@
"php": ">=5.3.0"
},
"autoload": {
"psr-0": { "Michelf": "" }
},
"extra": {
"branch-alias": {
"dev-lib": "1.4.x-dev"
}
"psr-4": { "Michelf\\": "Michelf/" }
}
}