aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/michelf/php-markdown/Michelf/Markdown.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/michelf/php-markdown/Michelf/Markdown.php')
-rw-r--r--vendor/michelf/php-markdown/Michelf/Markdown.php39
1 files changed, 19 insertions, 20 deletions
diff --git a/vendor/michelf/php-markdown/Michelf/Markdown.php b/vendor/michelf/php-markdown/Michelf/Markdown.php
index e4c2c2361..43b3c79e8 100644
--- a/vendor/michelf/php-markdown/Michelf/Markdown.php
+++ b/vendor/michelf/php-markdown/Michelf/Markdown.php
@@ -4,7 +4,7 @@
*
* @package php-markdown
* @author Michel Fortin <michel.fortin@michelf.com>
- * @copyright 2004-2018 Michel Fortin <https://michelf.com/projects/php-markdown/>
+ * @copyright 2004-2019 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.8.0";
+ const MARKDOWNLIB_VERSION = "1.9.0";
/**
* Simple function interface - Initialize the parser and return the result
@@ -85,25 +85,25 @@ class Markdown implements MarkdownInterface {
/**
* Optional filter function for URLs
- * @var callable
+ * @var callable|null
*/
public $url_filter_func = null;
/**
* Optional header id="" generation callback function.
- * @var callable
+ * @var callable|null
*/
public $header_id_func = null;
/**
* Optional function for converting code block content to HTML
- * @var callable
+ * @var callable|null
*/
public $code_block_content_func = null;
/**
* Optional function for converting code span content to HTML.
- * @var callable
+ * @var callable|null
*/
public $code_span_content_func = null;
@@ -767,16 +767,15 @@ class Markdown implements MarkdownInterface {
* @return string
*/
protected function _doAnchors_inline_callback($matches) {
- $whole_match = $matches[1];
$link_text = $this->runSpanGamut($matches[2]);
- $url = $matches[3] == '' ? $matches[4] : $matches[3];
+ $url = $matches[3] === '' ? $matches[4] : $matches[3];
$title =& $matches[7];
// If the URL was of the form <s p a c e s> it got caught by the HTML
// tag parser and hashed. Need to reverse the process before using
// the URL.
$unhashed = $this->unhash($url);
- if ($unhashed != $url)
+ if ($unhashed !== $url)
$url = preg_replace('/^<(.*)>$/', '\1', $unhashed);
$url = $this->encodeURLAttribute($url);
@@ -952,7 +951,7 @@ class Markdown implements MarkdownInterface {
return $matches[0];
}
- $level = $matches[2]{0} == '=' ? 1 : 2;
+ $level = $matches[2][0] == '=' ? 1 : 2;
// ID attribute generation
$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
@@ -1218,7 +1217,7 @@ class Markdown implements MarkdownInterface {
$codeblock = $matches[1];
$codeblock = $this->outdent($codeblock);
- if ($this->code_block_content_func) {
+ if (is_callable($this->code_block_content_func)) {
$codeblock = call_user_func($this->code_block_content_func, $codeblock, "");
} else {
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
@@ -1237,7 +1236,7 @@ class Markdown implements MarkdownInterface {
* @return string
*/
protected function makeCodeSpan($code) {
- if ($this->code_span_content_func) {
+ if (is_callable($this->code_span_content_func)) {
$code = call_user_func($this->code_span_content_func, $code);
} else {
$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
@@ -1358,7 +1357,7 @@ class Markdown implements MarkdownInterface {
} else {
// Other closing marker: close one em or strong and
// change current token state to match the other
- $token_stack[0] = str_repeat($token{0}, 3-$token_len);
+ $token_stack[0] = str_repeat($token[0], 3-$token_len);
$tag = $token_len == 2 ? "strong" : "em";
$span = $text_stack[0];
$span = $this->runSpanGamut($span);
@@ -1383,7 +1382,7 @@ class Markdown implements MarkdownInterface {
} else {
// Reached opening three-char emphasis marker. Push on token
// stack; will be handled by the special condition above.
- $em = $token{0};
+ $em = $token[0];
$strong = "$em$em";
array_unshift($token_stack, $token);
array_unshift($text_stack, '');
@@ -1576,11 +1575,11 @@ class Markdown implements MarkdownInterface {
* This function is *not* suitable for attributes enclosed in single quotes.
*
* @param string $url
- * @param string &$text Passed by reference
+ * @param string $text Passed by reference
* @return string URL
*/
protected function encodeURLAttribute($url, &$text = null) {
- if ($this->url_filter_func) {
+ if (is_callable($this->url_filter_func)) {
$url = call_user_func($this->url_filter_func, $url);
}
@@ -1694,7 +1693,7 @@ class Markdown implements MarkdownInterface {
* attribute special characters by Allan Odgaard.
*
* @param string $text
- * @param string &$tail
+ * @param string $tail Passed by reference
* @param integer $head_length
* @return string
*/
@@ -1792,13 +1791,13 @@ class Markdown implements MarkdownInterface {
* Handle $token provided by parseSpan by determining its nature and
* returning the corresponding value that should replace it.
* @param string $token
- * @param string &$str
+ * @param string $str Passed by reference
* @return string
*/
protected function handleSpanToken($token, &$str) {
- switch ($token{0}) {
+ switch ($token[0]) {
case "\\":
- return $this->hashPart("&#". ord($token{1}). ";");
+ return $this->hashPart("&#". ord($token[1]). ";");
case "`":
// Search for end marker in remaining text.
if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',