aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-10-12 09:09:55 +0000
committerMario <mario@mariovavti.com>2022-10-12 09:09:55 +0000
commitd3856caf81c96b1ea2615a375122ca85e91a6fb3 (patch)
tree9e506b96668b45e1ced0a2ec701007a17e277d7a /vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
parente1f9b1c47d8f3ed3400465ec279e894a0d9255c5 (diff)
downloadvolse-hubzilla-d3856caf81c96b1ea2615a375122ca85e91a6fb3.tar.gz
volse-hubzilla-d3856caf81c96b1ea2615a375122ca85e91a6fb3.tar.bz2
volse-hubzilla-d3856caf81c96b1ea2615a375122ca85e91a6fb3.zip
composer update michelf/php-markdown
Diffstat (limited to 'vendor/michelf/php-markdown/Michelf/MarkdownExtra.php')
-rw-r--r--vendor/michelf/php-markdown/Michelf/MarkdownExtra.php100
1 files changed, 38 insertions, 62 deletions
diff --git a/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php b/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
index 888f5f28d..e620f9e99 100644
--- a/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
+++ b/vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
@@ -4,7 +4,7 @@
*
* @package php-markdown
* @author Michel Fortin <michel.fortin@michelf.com>
- * @copyright 2004-2021 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 = '&#8617;&#xFE0E;';
+ public string $fn_backlink_html = '&#8617;&#xFE0E;';
/**
* 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|details|summary';
+ 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
@@ -1248,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);
@@ -1549,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_])',