Merge pull request #309 from NicolasCARPi/fixes

Various little fixes
This commit is contained in:
Michel Fortin 2018-08-13 16:59:49 -04:00 committed by GitHub
commit 93fa687d24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 12 deletions

View file

@ -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;
@ -1217,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);
@ -1236,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);
@ -1575,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);
}
@ -1693,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
*/
@ -1791,7 +1791,7 @@ 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) {

View file

@ -154,6 +154,10 @@ class MarkdownExtra extends \Michelf\Markdown {
*/
protected $footnote_counter = 1;
/**
* Ref attribute for links
* @var array
*/
protected $ref_attr = array();
/**
@ -733,8 +737,8 @@ class MarkdownExtra extends \Michelf\Markdown {
$tag = preg_replace($markdown_attr_re, '', $tag);
// Check if text inside this tag must be parsed in span mode.
$this->mode = $attr_m[2] . $attr_m[3];
$span_mode = $this->mode === 'span' || ($this->mode !== 'block' &&
$mode = $attr_m[2] . $attr_m[3];
$span_mode = $mode === 'span' || ($mode !== 'block' &&
preg_match('{^<(?:' . $this->contain_span_tags_re . ')\b}', $tag));
// Calculate indent before tag.