Skip to content

Commit 08d83c1

Browse files
committed
Update docs to php 8.1 and fix curly brace array/string access fatal errors
1 parent 0384e0e commit 08d83c1

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

docs/generate.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
2-
cat js-index.md | php5 jsToPhp.php > php-index.md
2+
cat js-index.md | php8.1 jsToPhp.php > php-index.md
33
cat php-patches.patch | patch php-index.md
4-
cat php-index.md | php5 mdToHtml.php > index.html
4+
cat php-index.md | php8.1 mdToHtml.php > index.html

docs/jparser-libs/jtokenizer.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/php-markdown/Michelf/Markdown.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ protected function _doHeaders_callback_setext($matches) {
794794
if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
795795
return $matches[0];
796796

797-
$level = $matches[2]{0} == '=' ? 1 : 2;
797+
$level = $matches[2][0] == '=' ? 1 : 2;
798798

799799
# id attribute generation
800800
$idAtt = $this->_generateIdFromHeaderValue($matches[1]);
@@ -1130,7 +1130,7 @@ protected function doItalicsAndBold($text) {
11301130
} else {
11311131
# Other closing marker: close one em or strong and
11321132
# change current token state to match the other
1133-
$token_stack[0] = str_repeat($token{0}, 3-$token_len);
1133+
$token_stack[0] = str_repeat($token[0], 3-$token_len);
11341134
$tag = $token_len == 2 ? "strong" : "em";
11351135
$span = $text_stack[0];
11361136
$span = $this->runSpanGamut($span);
@@ -1155,7 +1155,7 @@ protected function doItalicsAndBold($text) {
11551155
} else {
11561156
# Reached opening three-char emphasis marker. Push on token
11571157
# stack; will be handled by the special condition above.
1158-
$em = $token{0};
1158+
$em = $token[0];
11591159
$strong = "$em$em";
11601160
array_unshift($token_stack, $token);
11611161
array_unshift($text_stack, '');
@@ -1520,9 +1520,9 @@ protected function handleSpanToken($token, &$str) {
15201520
# Handle $token provided by parseSpan by determining its nature and
15211521
# returning the corresponding value that should replace it.
15221522
#
1523-
switch ($token{0}) {
1523+
switch ($token[0]) {
15241524
case "\\":
1525-
return $this->hashPart("&#". ord($token{1}). ";");
1525+
return $this->hashPart("&#". ord($token[1]). ";");
15261526
case "`":
15271527
# Search for end marker in remaining text.
15281528
if (preg_match('/^(.*?[^`])'.preg_quote($token).'(?!`)(.*)$/sm',

docs/php-markdown/Michelf/MarkdownExtra.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null) {
156156
$attributes = array();
157157
$id = false;
158158
foreach ($elements as $element) {
159-
if ($element{0} == '.') {
159+
if ($element[0] == '.') {
160160
$classes[] = substr($element, 1);
161-
} else if ($element{0} == '#') {
161+
} else if ($element[0] == '#') {
162162
if ($id === false) $id = substr($element, 1);
163163
} else if (strpos($element, '=') > 0) {
164164
$parts = explode('=', $element, 2);
@@ -429,7 +429,7 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
429429
#
430430
# Check for: Indented code block.
431431
#
432-
else if ($tag{0} == "\n" || $tag{0} == " ") {
432+
else if ($tag[0] == "\n" || $tag[0] == " ") {
433433
# Indented code block: pass it unchanged, will be handled
434434
# later.
435435
$parsed .= $tag;
@@ -438,7 +438,7 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
438438
# Check for: Code span marker
439439
# Note: need to check this after backtick fenced code blocks
440440
#
441-
else if ($tag{0} == "`") {
441+
else if ($tag[0] == "`") {
442442
# Find corresponding end marker.
443443
$tag_re = preg_quote($tag);
444444
if (preg_match('{^(?>.+?|\n(?!\n))*?(?<!`)'.$tag_re.'(?!`)}',
@@ -476,7 +476,7 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
476476
# HTML Comments, processing instructions.
477477
#
478478
else if (preg_match('{^<(?:'.$this->clean_tags_re.')\b}', $tag) ||
479-
$tag{1} == '!' || $tag{1} == '?')
479+
$tag[1] == '!' || $tag[1] == '?')
480480
{
481481
# Need to parse tag and following text using the HTML parser.
482482
# (don't check for markdown attribute)
@@ -495,8 +495,8 @@ protected function _hashHTMLBlocks_inMarkdown($text, $indent = 0,
495495
#
496496
# Increase/decrease nested tag count.
497497
#
498-
if ($tag{1} == '/') $depth--;
499-
else if ($tag{strlen($tag)-2} != '/') $depth++;
498+
if ($tag[1] == '/') $depth--;
499+
else if ($tag[strlen($tag)-2] != '/') $depth++;
500500

501501
if ($depth < 0) {
502502
#
@@ -600,7 +600,7 @@ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
600600
# first character as filtered to prevent an infinite loop in the
601601
# parent function.
602602
#
603-
return array($original_text{0}, substr($original_text, 1));
603+
return array($original_text[0], substr($original_text, 1));
604604
}
605605

606606
$block_text .= $parts[0]; # Text before current tag.
@@ -612,7 +612,7 @@ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
612612
# Comments and Processing Instructions.
613613
#
614614
if (preg_match('{^</?(?:'.$this->auto_close_tags_re.')\b}', $tag) ||
615-
$tag{1} == '!' || $tag{1} == '?')
615+
$tag[1] == '!' || $tag[1] == '?')
616616
{
617617
# Just add the tag to the block as if it was text.
618618
$block_text .= $tag;
@@ -623,8 +623,8 @@ protected function _hashHTMLBlocks_inHTML($text, $hash_method, $md_attr) {
623623
# the tag's name match base tag's.
624624
#
625625
if (preg_match('{^</?'.$base_tag_name_re.'\b}', $tag)) {
626-
if ($tag{1} == '/') $depth--;
627-
else if ($tag{strlen($tag)-2} != '/') $depth++;
626+
if ($tag[1] == '/') $depth--;
627+
else if ($tag[strlen($tag)-2] != '/') $depth++;
628628
}
629629

630630
#
@@ -988,7 +988,7 @@ protected function _doHeaders_callback_setext($matches) {
988988
if ($matches[3] == '-' && preg_match('{^- }', $matches[1]))
989989
return $matches[0];
990990

991-
$level = $matches[3]{0} == '=' ? 1 : 2;
991+
$level = $matches[3][0] == '=' ? 1 : 2;
992992

993993
$defaultId = is_callable($this->header_id_func) ? call_user_func($this->header_id_func, $matches[1]) : null;
994994

@@ -1323,7 +1323,7 @@ protected function _doFencedCodeBlocks_callback($matches) {
13231323
array($this, '_doFencedCodeBlocks_newlines'), $codeblock);
13241324

13251325
if ($classname != "") {
1326-
if ($classname{0} == '.')
1326+
if ($classname[0] == '.')
13271327
$classname = substr($classname, 1);
13281328
$attr_str = ' class="'.$this->code_class_prefix.$classname.'"';
13291329
} else {

0 commit comments

Comments
 (0)