8000 updated php-markdown to version 1.9.0 from current master by stephengaito · Pull Request #112 · devaneando/Wikitten · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

updated php-markdown to version 1.9.0 from current master #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions renderers/Markdown/License.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Original License for php-markdown files:

Markdown.php, MarkdownInterface.php and MarkdownExtra.php

taken from: https://github.com/michelf/php-markdown
from commit: 6975244af21bd467235217813f3473bf3929a208 (HEAD).
on: 2020/07/19

-------------------------------------------------------------------------

PHP Markdown Lib
Copyright (c) 2004-2019 Michel Fortin
<https://michelf.ca/>
All rights reserved.

Based on Markdown
Copyright (c) 2003-2006 John Gruber
<https://daringfireball.net/>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
41 changes: 20 additions & 21 deletions renderers/Markdown/Markdown.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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/>
*/

Expand All @@ -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
Expand Down Expand Up @@ -85,25 +85,25 @@ public static function defaultTransform($text) {

/**
* 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;

Expand Down Expand Up @@ -354,7 +354,7 @@ protected function hashHTMLBlocks($text) {
$block_tags_b_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|'.
'script|noscript|style|form|fieldset|iframe|math|svg|'.
'article|section|nav|aside|hgroup|header|footer|'.
'figure';
'figure|details|summary';

// Regular expression for the content of a block tag.
$nested_tags_level = 4;
Expand Down Expand Up @@ -767,16 +767,15 @@ protected function _doAnchors_reference_callback($matches) {
* @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);
Expand Down Expand Up @@ -952,7 +951,7 @@ protected function _doHeaders_callback_setext($matches) {
return $matches[0];
}

$level = $matches[2]{0} == '=' ? 1 : 2;
$level = $matches[2][0] == '=' ? 1 : 2;

// ID attribute generation
$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
Expand Down Expand Up @@ -1218,7 +1217,7 @@ protected function _doCodeBlocks_callback($matches) {
$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);
Expand All @@ -1237,7 +1236,7 @@ protected function _doCodeBlocks_callback($matches) {
* @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);
Expand Down Expand Up @@ -1358,7 +1357,7 @@ protected function doItalicsAndBold($text) {
} 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);
Expand All @@ -1383,7 +1382,7 @@ protected function doItalicsAndBold($text) {
} 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, '');
Expand Down Expand Up @@ -1576,11 +1575,11 @@ protected function encodeAttribute($text) {
* 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);
}

Expand Down Expand Up @@ -1694,7 +1693,7 @@ protected function _doAutoLinks_email_callback($matches) {
* attribute special characters by Allan Odgaard.
*
* @param string $text
* @param string &$tail
* @param string $tail Passed by reference
* @param integer $head_length
* @return string
*/
Expand Down Expand Up @@ -1792,13 +1791,13 @@ protected function parseSpan($str) {
* 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',
Expand Down
Loading
0