Merge branch 'MDL-75470-master' of https://github.com/davewoloszyn/moodle
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2018 Michel Fortin
|
||||
Copyright (c) 2004-2022 Michel Fortin
|
||||
<https://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
|
||||
+38
-58
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package php-markdown
|
||||
* @author Michel Fortin <[email protected]>
|
||||
* @copyright 2004-2019 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||
* @copyright 2004-2022 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.9.0";
|
||||
const MARKDOWNLIB_VERSION = "2.0.0";
|
||||
|
||||
/**
|
||||
* Simple function interface - Initialize the parser and return the result
|
||||
@@ -29,9 +29,9 @@ class Markdown implements MarkdownInterface {
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultTransform($text) {
|
||||
public static function defaultTransform(string $text): string {
|
||||
// Take parser class on which this function was called.
|
||||
$parser_class = \get_called_class();
|
||||
$parser_class = static::class;
|
||||
|
||||
// Try to take parser from the static parser list
|
||||
static $parser_list;
|
||||
@@ -49,39 +49,34 @@ class Markdown implements MarkdownInterface {
|
||||
/**
|
||||
* Configuration variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* Change to ">" for HTML output.
|
||||
* @var string
|
||||
*/
|
||||
public $empty_element_suffix = " />";
|
||||
public string $empty_element_suffix = " />";
|
||||
|
||||
/**
|
||||
* The width of indentation of the output markup
|
||||
* @var int
|
||||
*/
|
||||
public $tab_width = 4;
|
||||
public int $tab_width = 4;
|
||||
|
||||
/**
|
||||
* Change to `true` to disallow markup or entities.
|
||||
* @var boolean
|
||||
*/
|
||||
public $no_markup = false;
|
||||
public $no_entities = false;
|
||||
public bool $no_markup = false;
|
||||
public bool $no_entities = false;
|
||||
|
||||
|
||||
/**
|
||||
* Change to `true` to enable line breaks on \n without two trailling spaces
|
||||
* @var boolean
|
||||
*/
|
||||
public $hard_wrap = false;
|
||||
public bool $hard_wrap = false;
|
||||
|
||||
/**
|
||||
* Predefined URLs and titles for reference links and images.
|
||||
* @var array
|
||||
*/
|
||||
public $predef_urls = array();
|
||||
public $predef_titles = array();
|
||||
public array $predef_urls = array();
|
||||
public array $predef_titles = array();
|
||||
|
||||
/**
|
||||
* Optional filter function for URLs
|
||||
@@ -121,32 +116,27 @@ class Markdown implements MarkdownInterface {
|
||||
* <li>List item two</li>
|
||||
* <li>List item three</li>
|
||||
* </ol>
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enhanced_ordered_list = false;
|
||||
public bool $enhanced_ordered_list = false;
|
||||
|
||||
/**
|
||||
* Parser implementation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Regex to match balanced [brackets].
|
||||
* Needed to insert a maximum bracked depth while converting to PHP.
|
||||
* @var int
|
||||
*/
|
||||
protected $nested_brackets_depth = 6;
|
||||
protected $nested_brackets_re;
|
||||
protected int $nested_brackets_depth = 6;
|
||||
protected string $nested_brackets_re;
|
||||
|
||||
protected $nested_url_parenthesis_depth = 4;
|
||||
protected $nested_url_parenthesis_re;
|
||||
protected int $nested_url_parenthesis_depth = 4;
|
||||
protected string $nested_url_parenthesis_re;
|
||||
|
||||
/**
|
||||
* Table of hash values for escaped characters:
|
||||
* @var string
|
||||
*/
|
||||
protected $escape_chars = '\`*_{}[]()>#+-.!';
|
||||
protected $escape_chars_re;
|
||||
protected string $escape_chars = '\`*_{}[]()>#+-.!';
|
||||
protected string $escape_chars_re;
|
||||
|
||||
/**
|
||||
* Constructor function. Initialize appropriate member variables.
|
||||
@@ -175,23 +165,20 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Internal hashes used during transformation.
|
||||
* @var array
|
||||
*/
|
||||
protected $urls = array();
|
||||
protected $titles = array();
|
||||
protected $html_hashes = array();
|
||||
protected array $urls = array();
|
||||
protected array $titles = array();
|
||||
protected array $html_hashes = array();
|
||||
|
||||
/**
|
||||
* Status flag to avoid invalid nesting.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $in_anchor = false;
|
||||
protected bool $in_anchor = false;
|
||||
|
||||
/**
|
||||
* Status flag to avoid invalid nesting.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $in_emphasis_processing = false;
|
||||
protected bool $in_emphasis_processing = false;
|
||||
|
||||
/**
|
||||
* Called before the transformation process starts to setup parser states.
|
||||
@@ -226,7 +213,7 @@ class Markdown implements MarkdownInterface {
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function transform($text) {
|
||||
public function transform(string $text): string {
|
||||
$this->setup();
|
||||
|
||||
# Remove UTF-8 BOM and marker character in input, if present.
|
||||
@@ -263,9 +250,8 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Define the document gamut
|
||||
* @var array
|
||||
*/
|
||||
protected $document_gamut = array(
|
||||
protected array $document_gamut = array(
|
||||
// Strip link definitions, store in hashes.
|
||||
"stripLinkDefinitions" => 20,
|
||||
"runBasicBlockGamut" => 30,
|
||||
@@ -354,7 +340,7 @@ class Markdown implements MarkdownInterface {
|
||||
$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;
|
||||
@@ -525,9 +511,8 @@ class Markdown implements MarkdownInterface {
|
||||
/**
|
||||
* Define the block gamut - these are all the transformations that form
|
||||
* block-level tags like paragraphs, headers, and list items.
|
||||
* @var array
|
||||
*/
|
||||
protected $block_gamut = array(
|
||||
protected array $block_gamut = array(
|
||||
"doHeaders" => 10,
|
||||
"doHorizontalRules" => 20,
|
||||
"doLists" => 40,
|
||||
@@ -597,9 +582,8 @@ class Markdown implements MarkdownInterface {
|
||||
/**
|
||||
* These are all the transformations that occur *within* block-level
|
||||
* tags like paragraphs, headers, and list items.
|
||||
* @var array
|
||||
*/
|
||||
protected $span_gamut = array(
|
||||
protected array $span_gamut = array(
|
||||
// Process character escapes, code spans, and inline HTML
|
||||
// in one shot.
|
||||
"parseSpan" => -30,
|
||||
@@ -724,7 +708,7 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Callback method to parse referenced anchors
|
||||
* @param string $matches
|
||||
* @param array $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function _doAnchors_reference_callback($matches) {
|
||||
@@ -763,7 +747,7 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Callback method to parse inline anchors
|
||||
* @param string $matches
|
||||
* @param array $matches
|
||||
* @return string
|
||||
*/
|
||||
protected function _doAnchors_inline_callback($matches) {
|
||||
@@ -781,7 +765,7 @@ class Markdown implements MarkdownInterface {
|
||||
$url = $this->encodeURLAttribute($url);
|
||||
|
||||
$result = "<a href=\"$url\"";
|
||||
if (isset($title)) {
|
||||
if ($title) {
|
||||
$title = $this->encodeAttribute($title);
|
||||
$result .= " title=\"$title\"";
|
||||
}
|
||||
@@ -1105,9 +1089,8 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Nesting tracker for list levels
|
||||
* @var integer
|
||||
*/
|
||||
protected $list_level = 0;
|
||||
protected int $list_level = 0;
|
||||
|
||||
/**
|
||||
* Process the contents of a single ordered or unordered list, splitting it
|
||||
@@ -1248,7 +1231,7 @@ class Markdown implements MarkdownInterface {
|
||||
* Define the emphasis operators with their regex matches
|
||||
* @var array
|
||||
*/
|
||||
protected $em_relist = array(
|
||||
protected array $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?![\.,:;]?\s)',
|
||||
'*' => '(?<![\s*])\*(?!\*)',
|
||||
'_' => '(?<![\s_])_(?!_)',
|
||||
@@ -1258,7 +1241,7 @@ class Markdown implements MarkdownInterface {
|
||||
* Define the strong operators with their regex matches
|
||||
* @var array
|
||||
*/
|
||||
protected $strong_relist = array(
|
||||
protected array $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?![\.,:;]?\s)',
|
||||
'**' => '(?<![\s*])\*\*(?!\*)',
|
||||
'__' => '(?<![\s_])__(?!_)',
|
||||
@@ -1268,7 +1251,7 @@ class Markdown implements MarkdownInterface {
|
||||
* Define the emphasis + strong operators with their regex matches
|
||||
* @var array
|
||||
*/
|
||||
protected $em_strong_relist = array(
|
||||
protected array $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?![\.,:;]?\s)',
|
||||
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
||||
'___' => '(?<![\s_])___(?!_)',
|
||||
@@ -1276,9 +1259,8 @@ class Markdown implements MarkdownInterface {
|
||||
|
||||
/**
|
||||
* Container for prepared regular expressions
|
||||
* @var array
|
||||
*/
|
||||
protected $em_strong_prepared_relist;
|
||||
protected ?array $em_strong_prepared_relist = null;
|
||||
|
||||
/**
|
||||
* Prepare regular expressions for searching emphasis tokens in any
|
||||
@@ -1826,7 +1808,7 @@ class Markdown implements MarkdownInterface {
|
||||
/**
|
||||
* String length function for detab. `_initDetab` will create a function to
|
||||
* handle UTF-8 if the default function does not exist.
|
||||
* @var string
|
||||
* can be a string or function
|
||||
*/
|
||||
protected $utf8_strlen = 'mb_strlen';
|
||||
|
||||
@@ -1883,9 +1865,7 @@ class Markdown implements MarkdownInterface {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->utf8_strlen = function($text) {
|
||||
return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
|
||||
};
|
||||
$this->utf8_strlen = fn($text) => preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package php-markdown
|
||||
* @author Michel Fortin <[email protected]>
|
||||
* @copyright 2004-2019 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||
* @copyright 2004-2022 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
|
||||
*/
|
||||
|
||||
@@ -17,25 +17,21 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
/**
|
||||
* Configuration variables
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prefix for footnote ids.
|
||||
* @var string
|
||||
*/
|
||||
public $fn_id_prefix = "";
|
||||
public string $fn_id_prefix = "";
|
||||
|
||||
/**
|
||||
* Optional title attribute for footnote links.
|
||||
* @var string
|
||||
*/
|
||||
public $fn_link_title = "";
|
||||
public string $fn_link_title = "";
|
||||
|
||||
/**
|
||||
* Optional class attribute for footnote links and backlinks.
|
||||
* @var string
|
||||
*/
|
||||
public $fn_link_class = "footnote-ref";
|
||||
public $fn_backlink_class = "footnote-backref";
|
||||
public string $fn_link_class = "footnote-ref";
|
||||
public string $fn_backlink_class = "footnote-backref";
|
||||
|
||||
/**
|
||||
* Content to be displayed within footnote backlinks. The default is '↩';
|
||||
@@ -43,59 +39,51 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
* from displaying the arrow character as an emoji.
|
||||
* Optionally use '^^' and '%%' to refer to the footnote number and
|
||||
* reference number respectively. {@see parseFootnotePlaceholders()}
|
||||
* @var string
|
||||
*/
|
||||
public $fn_backlink_html = '↩︎';
|
||||
public string $fn_backlink_html = '↩︎';
|
||||
|
||||
/**
|
||||
* Optional title and aria-label attributes for footnote backlinks for
|
||||
* added accessibility (to ensure backlink uniqueness).
|
||||
* Use '^^' and '%%' to refer to the footnote number and reference number
|
||||
* respectively. {@see parseFootnotePlaceholders()}
|
||||
* @var string
|
||||
*/
|
||||
public $fn_backlink_title = "";
|
||||
public $fn_backlink_label = "";
|
||||
public string $fn_backlink_title = "";
|
||||
public string $fn_backlink_label = "";
|
||||
|
||||
/**
|
||||
* Class name for table cell alignment (%% replaced left/center/right)
|
||||
* For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center'
|
||||
* If empty, the align attribute is used instead of a class name.
|
||||
* @var string
|
||||
*/
|
||||
public $table_align_class_tmpl = '';
|
||||
public string $table_align_class_tmpl = '';
|
||||
|
||||
/**
|
||||
* Optional class prefix for fenced code block.
|
||||
* @var string
|
||||
*/
|
||||
public $code_class_prefix = "";
|
||||
public string $code_class_prefix = "";
|
||||
|
||||
/**
|
||||
* Class attribute for code blocks goes on the `code` tag;
|
||||
* setting this to true will put attributes on the `pre` tag instead.
|
||||
* @var boolean
|
||||
*/
|
||||
public $code_attr_on_pre = false;
|
||||
public bool $code_attr_on_pre = false;
|
||||
|
||||
/**
|
||||
* Predefined abbreviations.
|
||||
* @var array
|
||||
*/
|
||||
public $predef_abbr = array();
|
||||
public array $predef_abbr = array();
|
||||
|
||||
/**
|
||||
* Only convert atx-style headers if there's a space between the header and #
|
||||
* @var boolean
|
||||
*/
|
||||
public $hashtag_protection = false;
|
||||
public bool $hashtag_protection = false;
|
||||
|
||||
/**
|
||||
* Determines whether footnotes should be appended to the end of the document.
|
||||
* If true, footnote html can be retrieved from $this->footnotes_assembled.
|
||||
* @var boolean
|
||||
*/
|
||||
public $omit_footnotes = false;
|
||||
public bool $omit_footnotes = false;
|
||||
|
||||
|
||||
/**
|
||||
@@ -107,9 +95,8 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
* `section` that will enclose the list of footnotes so they are
|
||||
* reachable to accessibility tools the same way they would be with the
|
||||
* default HTML output.
|
||||
* @var null|string
|
||||
*/
|
||||
public $footnotes_assembled = null;
|
||||
public ?string $footnotes_assembled = null;
|
||||
|
||||
/**
|
||||
* Parser implementation
|
||||
@@ -149,27 +136,23 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
|
||||
/**
|
||||
* Extra variables used during extra transformations.
|
||||
* @var array
|
||||
*/
|
||||
protected $footnotes = array();
|
||||
protected $footnotes_ordered = array();
|
||||
protected $footnotes_ref_count = array();
|
||||
protected $footnotes_numbers = array();
|
||||
protected $abbr_desciptions = array();
|
||||
/** @var string */
|
||||
protected $abbr_word_re = '';
|
||||
protected array $footnotes = array();
|
||||
protected array $footnotes_ordered = array();
|
||||
protected array $footnotes_ref_count = array();
|
||||
protected array $footnotes_numbers = array();
|
||||
protected array $abbr_desciptions = array();
|
||||
protected string $abbr_word_re = '';
|
||||
|
||||
/**
|
||||
* Give the current footnote number.
|
||||
* @var integer
|
||||
*/
|
||||
protected $footnote_counter = 1;
|
||||
protected int $footnote_counter = 1;
|
||||
|
||||
/**
|
||||
* Ref attribute for links
|
||||
* @var array
|
||||
*/
|
||||
protected $ref_attr = array();
|
||||
* Ref attribute for links
|
||||
*/
|
||||
protected array $ref_attr = array();
|
||||
|
||||
/**
|
||||
* Setting up Extra-specific variables.
|
||||
@@ -215,18 +198,15 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
/**
|
||||
* Extra attribute parser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Expression to use to catch attributes (includes the braces)
|
||||
* @var string
|
||||
*/
|
||||
protected $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
|
||||
protected string $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
|
||||
|
||||
/**
|
||||
* Expression to use when parsing in a context when no capture is desired
|
||||
* @var string
|
||||
*/
|
||||
protected $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
|
||||
protected string $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
|
||||
|
||||
/**
|
||||
* Parse attributes caught by the $this->id_class_attr_catch_re expression
|
||||
@@ -340,37 +320,31 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
/**
|
||||
* HTML block parser
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tags that are always treated as block tags
|
||||
* @var string
|
||||
*/
|
||||
protected $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure';
|
||||
protected string $block_tags_re = 'p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|address|form|fieldset|iframe|hr|legend|article|section|nav|aside|hgroup|header|footer|figcaption|figure|details|summary';
|
||||
|
||||
/**
|
||||
* Tags treated as block tags only if the opening tag is alone on its line
|
||||
* @var string
|
||||
*/
|
||||
protected $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
||||
protected string $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
|
||||
|
||||
/**
|
||||
* Tags where markdown="1" default to span mode:
|
||||
* @var string
|
||||
*/
|
||||
protected $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
||||
protected string $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
|
||||
|
||||
/**
|
||||
* Tags which must not have their contents modified, no matter where
|
||||
* they appear
|
||||
* @var string
|
||||
*/
|
||||
protected $clean_tags_re = 'script|style|math|svg';
|
||||
protected string $clean_tags_re = 'script|style|math|svg';
|
||||
|
||||
/**
|
||||
* Tags that do not need to be closed.
|
||||
* @var string
|
||||
*/
|
||||
protected $auto_close_tags_re = 'hr|img|param|source|track';
|
||||
protected string $auto_close_tags_re = 'hr|img|param|source|track';
|
||||
|
||||
/**
|
||||
* Hashify HTML Blocks and "clean tags".
|
||||
@@ -627,6 +601,7 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
else {
|
||||
$parsed .= $tag;
|
||||
}
|
||||
// @phpstan-ignore-next-line
|
||||
} while ($depth >= 0);
|
||||
|
||||
return array($parsed, $text);
|
||||
@@ -708,7 +683,7 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
// by the pattern.
|
||||
$parts = preg_split($tag_re, $text, 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
|
||||
if (count($parts) < 3) {
|
||||
if ($parts === false || count($parts) < 3) {
|
||||
// End of $text reached with unbalenced tag(s).
|
||||
// In that case, we return original text unchanged and pass the
|
||||
// first character as filtered to prevent an infinite loop in the
|
||||
@@ -932,6 +907,7 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
protected function _doAnchors_inline_callback($matches) {
|
||||
$link_text = $this->runSpanGamut($matches[2]);
|
||||
$url = $matches[3] === '' ? $matches[4] : $matches[3];
|
||||
$title_quote =& $matches[6];
|
||||
$title =& $matches[7];
|
||||
$attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
|
||||
|
||||
@@ -944,7 +920,7 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
$url = $this->encodeURLAttribute($url);
|
||||
|
||||
$result = "<a href=\"$url\"";
|
||||
if (isset($title)) {
|
||||
if (isset($title) && $title_quote) {
|
||||
$title = $this->encodeAttribute($title);
|
||||
$result .= " title=\"$title\"";
|
||||
}
|
||||
@@ -1056,13 +1032,14 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
protected function _doImages_inline_callback($matches) {
|
||||
$alt_text = $matches[2];
|
||||
$url = $matches[3] === '' ? $matches[4] : $matches[3];
|
||||
$title_quote =& $matches[6];
|
||||
$title =& $matches[7];
|
||||
$attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
|
||||
|
||||
$alt_text = $this->encodeAttribute($alt_text);
|
||||
$url = $this->encodeURLAttribute($url);
|
||||
$result = "<img src=\"$url\" alt=\"$alt_text\"";
|
||||
if (isset($title)) {
|
||||
if (isset($title) && $title_quote) {
|
||||
$title = $this->encodeAttribute($title);
|
||||
$result .= " title=\"$title\""; // $title already quoted
|
||||
}
|
||||
@@ -1246,6 +1223,7 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
$head = $matches[1];
|
||||
$underline = $matches[2];
|
||||
$content = $matches[3];
|
||||
$attr = [];
|
||||
|
||||
// Remove any tailing pipes for each line.
|
||||
$head = preg_replace('/[|] *$/m', '', $head);
|
||||
@@ -1547,17 +1525,17 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
* work in the middle of a word.
|
||||
* @var array
|
||||
*/
|
||||
protected $em_relist = array(
|
||||
protected array $em_relist = array(
|
||||
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?![\.,:;]?\s)',
|
||||
'*' => '(?<![\s*])\*(?!\*)',
|
||||
'_' => '(?<![\s_])_(?![a-zA-Z0-9_])',
|
||||
);
|
||||
protected $strong_relist = array(
|
||||
protected array $strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?![\.,:;]?\s)',
|
||||
'**' => '(?<![\s*])\*\*(?!\*)',
|
||||
'__' => '(?<![\s_])__(?![a-zA-Z0-9_])',
|
||||
);
|
||||
protected $em_strong_relist = array(
|
||||
protected array $em_strong_relist = array(
|
||||
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?![\.,:;]?\s)',
|
||||
'***' => '(?<![\s*])\*\*\*(?!\*)',
|
||||
'___' => '(?<![\s_])___(?![a-zA-Z0-9_])',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @package php-markdown
|
||||
* @author Michel Fortin <[email protected]>
|
||||
* @copyright 2004-2019 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||
* @copyright 2004-2022 Michel Fortin <https://michelf.com/projects/php-markdown/>
|
||||
* @copyright (Original Markdown) 2004-2006 John Gruber <https://daringfireball.net/projects/markdown/>
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ interface MarkdownInterface {
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public static function defaultTransform($text);
|
||||
public static function defaultTransform(string $text): string;
|
||||
|
||||
/**
|
||||
* Main function. Performs some preprocessing on the input text
|
||||
@@ -34,5 +34,5 @@ interface MarkdownInterface {
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
public function transform($text);
|
||||
public function transform(string $text): string;
|
||||
}
|
||||
|
||||
+30
-6
@@ -1,7 +1,7 @@
|
||||
PHP Markdown
|
||||
============
|
||||
|
||||
PHP Markdown Lib 1.9.0 - 1 Dec 2019
|
||||

|
||||
|
||||
by Michel Fortin
|
||||
<https://michelf.ca/>
|
||||
@@ -34,15 +34,14 @@ program by John Gruber.
|
||||
Requirement
|
||||
-----------
|
||||
|
||||
This library package requires PHP 5.3 or later.
|
||||
This library package requires PHP 7.4 or later.
|
||||
|
||||
Note: The older plugin/library hybrid package for PHP Markdown and
|
||||
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
|
||||
releases defaults to 1 000 000, which is usually fine.
|
||||
You might need to set pcre.backtrack_limit higher than 1 000 000
|
||||
(the default), though the default is usually fine.
|
||||
|
||||
|
||||
Usage
|
||||
@@ -183,6 +182,31 @@ PHP Markdown, please visit [michelf.ca/donate].
|
||||
Version History
|
||||
---------------
|
||||
|
||||
PHP Markdown Lib 2.0.0 (26 Sep 2022)
|
||||
|
||||
* Now requiring PHP version 7.4 or later.
|
||||
|
||||
* Added type annotations to configuration properties of the parser.
|
||||
(Thanks to Tac Tacelosky.)
|
||||
|
||||
* Fixing a TypeError in PHP 8 caused by invalid counter variable.
|
||||
(Thanks to Alexey Kopytko.)
|
||||
|
||||
* Composer package now excludes development files.
|
||||
(Thanks to Cédric Anne.)
|
||||
|
||||
|
||||
PHP Markdown Lib 1.9.1 (23 Nov 2021)
|
||||
|
||||
* Now treating `<details>` and `<summary>` as block level so they don't
|
||||
get wrapped in `<p>`.
|
||||
(Thanks to Thomas Hochstein for the fix.)
|
||||
|
||||
* Fix for unintended blank title attribute when adding supplementary attributes
|
||||
to a link in Markdown Extra.
|
||||
(Thanks to Richie Black for the fix.)
|
||||
|
||||
|
||||
PHP Markdown Lib 1.9.0 (1 Dec 2019)
|
||||
|
||||
* Added `fn_backlink_label` configuration variable to put some text in the
|
||||
@@ -399,7 +423,7 @@ Copyright and License
|
||||
---------------------
|
||||
|
||||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2019 Michel Fortin
|
||||
Copyright (c) 2004-2022 Michel Fortin
|
||||
<https://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
Description of Markdown Extra import into Moodle
|
||||
|
||||
Procedure:
|
||||
* download latest version from http://michelf.ca/projects/php-markdown/
|
||||
* copy the classes and readme file to lib/markdown/* , Note .inc files need not be copied.
|
||||
* update function markdown_to_html() in weblib.php if necessary,
|
||||
* download latest version from https://github.com/michelf/php-markdown/tags
|
||||
* copy the classes and Readme.md file to lib/markdown/* , Note .inc files need not be copied.
|
||||
* update function markdown_to_html() in lib/weblib.php if necessary,
|
||||
note that we require the php files manually for performance reasons
|
||||
* run phpunit tests (all PHP versions)
|
||||
|
||||
Petr Skoda
|
||||
|
||||
* Removed fixup step in procedure
|
||||
* Currently using the 1.9.0 release(includes php74 fixup commit)
|
||||
|
||||
Peter Dias
|
||||
|
||||
@@ -246,7 +246,7 @@
|
||||
<location>markdown</location>
|
||||
<name>Markdown</name>
|
||||
<description>Functions to convert from the Markdown text format into clean XHTML.</description>
|
||||
<version>1.9.0</version>
|
||||
<version>2.0.0</version>
|
||||
<license>BSD</license>
|
||||
<repository>https://github.com/michelf/php-markdown</repository>
|
||||
<copyrights>
|
||||
|
||||
Reference in New Issue
Block a user