Skip to content

Commit

Permalink
Re-add PHP 7.3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
za3k committed Apr 21, 2022
1 parent c492201 commit 13e1695
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
50 changes: 25 additions & 25 deletions Michelf/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ public static function defaultTransform($text) {
/**
* Change to ">" for HTML output.
*/
public string $empty_element_suffix = " />";
public $empty_element_suffix = " />";

/**
* The width of indentation of the output markup
*/
public int $tab_width = 4;
public $tab_width = 4;

/**
* Change to `true` to disallow markup or entities.
*/
public bool $no_markup = false;
public bool $no_entities = false;
public $no_markup = false;
public $no_entities = false;


/**
* Change to `true` to enable line breaks on \n without two trailling spaces
* @var boolean
*/
public bool $hard_wrap = false;
public $hard_wrap = false;

/**
* Predefined URLs and titles for reference links and images.
*/
public array $predef_urls = array();
public array $predef_titles = array();
public $predef_urls = array();
public $predef_titles = array();

/**
* Optional filter function for URLs
Expand Down Expand Up @@ -117,7 +117,7 @@ public static function defaultTransform($text) {
* <li>List item three</li>
* </ol>
*/
public bool $enhanced_ordered_list = false;
public $enhanced_ordered_list = false;

/**
* Parser implementation
Expand All @@ -126,17 +126,17 @@ public static function defaultTransform($text) {
* Regex to match balanced [brackets].
* Needed to insert a maximum bracked depth while converting to PHP.
*/
protected int $nested_brackets_depth = 6;
protected $nested_brackets_depth = 6;
protected $nested_brackets_re;

protected int $nested_url_parenthesis_depth = 4;
protected $nested_url_parenthesis_depth = 4;
protected $nested_url_parenthesis_re;

/**
* Table of hash values for escaped characters:
*/
protected string $escape_chars = '\`*_{}[]()>#+-.!';
protected string $escape_chars_re;
protected $escape_chars = '\`*_{}[]()>#+-.!';
protected $escape_chars_re;

/**
* Constructor function. Initialize appropriate member variables.
Expand Down Expand Up @@ -166,19 +166,19 @@ public function __construct() {
/**
* Internal hashes used during transformation.
*/
protected array $urls = array();
protected $urls = array();
protected $titles = array();
protected array $html_hashes = array();
protected $html_hashes = array();

/**
* Status flag to avoid invalid nesting.
*/
protected bool $in_anchor = false;
protected $in_anchor = false;

/**
* Status flag to avoid invalid nesting.
*/
protected bool $in_emphasis_processing = false;
protected $in_emphasis_processing = false;

/**
* Called before the transformation process starts to setup parser states.
Expand Down Expand Up @@ -251,7 +251,7 @@ public function transform($text) {
/**
* Define the document gamut
*/
protected array $document_gamut = array(
protected $document_gamut = array(
// Strip link definitions, store in hashes.
"stripLinkDefinitions" => 20,
"runBasicBlockGamut" => 30,
Expand Down Expand Up @@ -512,7 +512,7 @@ protected function hashBlock($text) {
* Define the block gamut - these are all the transformations that form
* block-level tags like paragraphs, headers, and list items.
*/
protected array $block_gamut = array(
protected $block_gamut = array(
"doHeaders" => 10,
"doHorizontalRules" => 20,
"doLists" => 40,
Expand Down Expand Up @@ -583,7 +583,7 @@ protected function doHorizontalRules($text) {
* These are all the transformations that occur *within* block-level
* tags like paragraphs, headers, and list items.
*/
protected array $span_gamut = array(
protected $span_gamut = array(
// Process character escapes, code spans, and inline HTML
// in one shot.
"parseSpan" => -30,
Expand Down Expand Up @@ -1090,7 +1090,7 @@ protected function _doLists_callback($matches) {
/**
* Nesting tracker for list levels
*/
protected int $list_level = 0;
protected $list_level = 0;

/**
* Process the contents of a single ordered or unordered list, splitting it
Expand Down Expand Up @@ -1231,7 +1231,7 @@ protected function makeCodeSpan($code) {
* Define the emphasis operators with their regex matches
* @var array
*/
protected array $em_relist = array(
protected $em_relist = array(
'' => '(?:(?<!\*)\*(?!\*)|(?<!_)_(?!_))(?![\.,:;]?\s)',
'*' => '(?<![\s*])\*(?!\*)',
'_' => '(?<![\s_])_(?!_)',
Expand All @@ -1241,7 +1241,7 @@ protected function makeCodeSpan($code) {
* Define the strong operators with their regex matches
* @var array
*/
protected array $strong_relist = array(
protected $strong_relist = array(
'' => '(?:(?<!\*)\*\*(?!\*)|(?<!_)__(?!_))(?![\.,:;]?\s)',
'**' => '(?<![\s*])\*\*(?!\*)',
'__' => '(?<![\s_])__(?!_)',
Expand All @@ -1251,7 +1251,7 @@ protected function makeCodeSpan($code) {
* Define the emphasis + strong operators with their regex matches
* @var array
*/
protected array $em_strong_relist = array(
protected $em_strong_relist = array(
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<!_)___(?!_))(?![\.,:;]?\s)',
'***' => '(?<![\s*])\*\*\*(?!\*)',
'___' => '(?<![\s_])___(?!_)',
Expand All @@ -1260,7 +1260,7 @@ protected function makeCodeSpan($code) {
/**
* Container for prepared regular expressions
*/
protected ?array $em_strong_prepared_relist = null;
protected $em_strong_prepared_relist = null;

/**
* Prepare regular expressions for searching emphasis tokens in any
Expand Down Expand Up @@ -1865,7 +1865,7 @@ protected function _initDetab() {
return;
}

$this->utf8_strlen = fn($text) => preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m);
$this->utf8_strlen = function ($text) { return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', $text, $m); };
}

/**
Expand Down
64 changes: 32 additions & 32 deletions Michelf/MarkdownExtra.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ class MarkdownExtra extends \Michelf\Markdown {
/**
* Prefix for footnote ids.
*/
public string $fn_id_prefix = "";
public $fn_id_prefix = "";

/**
* Optional title attribute for footnote links.
*/
public string $fn_link_title = "";
public $fn_link_title = "";

/**
* Optional class attribute for footnote links and backlinks.
*/
public string $fn_link_class = "footnote-ref";
public string $fn_backlink_class = "footnote-backref";
public $fn_link_class = "footnote-ref";
public $fn_backlink_class = "footnote-backref";

/**
* Content to be displayed within footnote backlinks. The default is '↩';
Expand All @@ -40,50 +40,50 @@ class MarkdownExtra extends \Michelf\Markdown {
* Optionally use '^^' and '%%' to refer to the footnote number and
* reference number respectively. {@see parseFootnotePlaceholders()}
*/
public string $fn_backlink_html = '&#8617;&#xFE0E;';
public $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()}
*/
public string $fn_backlink_title = "";
public string $fn_backlink_label = "";
public $fn_backlink_title = "";
public $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.
*/
public string $table_align_class_tmpl = '';
public $table_align_class_tmpl = '';

/**
* Optional class prefix for fenced code block.
*/
public string $code_class_prefix = "";
public $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.
*/
public bool $code_attr_on_pre = false;
public $code_attr_on_pre = false;

/**
* Predefined abbreviations.
*/
public array $predef_abbr = array();
public $predef_abbr = array();

/**
* Only convert atx-style headers if there's a space between the header and #
*/
public bool $hashtag_protection = false;
public $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.
*/
public bool $omit_footnotes = false;
public $omit_footnotes = false;


/**
Expand All @@ -96,7 +96,7 @@ class MarkdownExtra extends \Michelf\Markdown {
* reachable to accessibility tools the same way they would be with the
* default HTML output.
*/
public ?string $footnotes_assembled = null;
public $footnotes_assembled = null;

/**
* Parser implementation
Expand Down Expand Up @@ -137,22 +137,22 @@ public function __construct() {
/**
* Extra variables used during extra transformations.
*/
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 = '';
protected $footnotes = array();
protected $footnotes_ordered = array();
protected $footnotes_ref_count = array();
protected $footnotes_numbers = array();
protected $abbr_desciptions = array();
protected $abbr_word_re = '';

/**
* Give the current footnote number.
*/
protected int $footnote_counter = 1;
protected $footnote_counter = 1;

/**
* Ref attribute for links
*/
protected array $ref_attr = array();
protected $ref_attr = array();

/**
* Setting up Extra-specific variables.
Expand Down Expand Up @@ -201,12 +201,12 @@ protected function teardown() {
/**
* Expression to use to catch attributes (includes the braces)
*/
protected string $id_class_attr_catch_re = '\{((?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,})[ ]*\}';
protected $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
*/
protected string $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';
protected $id_class_attr_nocatch_re = '\{(?>[ ]*[#.a-z][-_:a-zA-Z0-9=]+){1,}[ ]*\}';

/**
* Parse attributes caught by the $this->id_class_attr_catch_re expression
Expand Down Expand Up @@ -323,28 +323,28 @@ protected function _stripLinkDefinitions_callback($matches) {
/**
* Tags that are always treated as block tags
*/
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';
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';

/**
* Tags treated as block tags only if the opening tag is alone on its line
*/
protected string $context_block_tags_re = 'script|noscript|style|ins|del|iframe|object|source|track|param|math|svg|canvas|audio|video';
protected $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:
*/
protected string $contain_span_tags_re = 'p|h[1-6]|li|dd|dt|td|th|legend|address';
protected $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
*/
protected string $clean_tags_re = 'script|style|math|svg';
protected $clean_tags_re = 'script|style|math|svg';

/**
* Tags that do not need to be closed.
*/
protected string $auto_close_tags_re = 'hr|img|param|source|track';
protected $auto_close_tags_re = 'hr|img|param|source|track';

/**
* Hashify HTML Blocks and "clean tags".
Expand Down Expand Up @@ -1524,17 +1524,17 @@ protected function _doFencedCodeBlocks_newlines($matches) {
* work in the middle of a word.
* @var array
*/
protected array $em_relist = array(
protected $em_relist = array(
'' => '(?:(?<!\*)\*(?!\*)|(?<![a-zA-Z0-9_])_(?!_))(?![\.,:;]?\s)',
'*' => '(?<![\s*])\*(?!\*)',
'_' => '(?<![\s_])_(?![a-zA-Z0-9_])',
);
protected array $strong_relist = array(
protected $strong_relist = array(
'' => '(?:(?<!\*)\*\*(?!\*)|(?<![a-zA-Z0-9_])__(?!_))(?![\.,:;]?\s)',
'**' => '(?<![\s*])\*\*(?!\*)',
'__' => '(?<![\s_])__(?![a-zA-Z0-9_])',
);
protected array $em_strong_relist = array(
protected $em_strong_relist = array(
'' => '(?:(?<!\*)\*\*\*(?!\*)|(?<![a-zA-Z0-9_])___(?!_))(?![\.,:;]?\s)',
'***' => '(?<![\s*])\*\*\*(?!\*)',
'___' => '(?<![\s_])___(?![a-zA-Z0-9_])',
Expand Down

0 comments on commit 13e1695

Please sign in to comment.