Skip to content

Commit

Permalink
Fix global html_id
Browse files Browse the repository at this point in the history
(and learn to count)
  • Loading branch information
bloatware committed Jun 18, 2021
1 parent ded06b9 commit 21c8e6e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
35 changes: 35 additions & 0 deletions textpattern/lib/txplib_misc.php
Expand Up @@ -5960,6 +5960,41 @@ function txp_break($wraptag)
}
}

// -------------------------------------------------------------

function txp_substr($string, $first = 1, $last = null, $tidy = false)
{
$strlen = mb_strlen($string);
$first >= 0 or $first = $strlen + $first + 1;
$last = !isset($last) ? $first : ($last >= 0 ? $last : $strlen + $last + 1);

if ($first > $last) {
list($first, $last) = array($last, $first);
$gnirts = '';
}

if ($first > $strlen || $last < 1) {
return '';
}

if ($tidy) {
$pattern = '/^'.($first > 0 ? '(?U:.{'.(--$first).',})\b' : '').'(.*)'.($last <= $strlen ? '\b.{'.($strlen - $last).',}' : '').'$/su';
$string = preg_replace($pattern, '$1', $string);
} else {
$string = mb_substr($string, --$first, $last - $first);
}

if (isset($gnirts)) {return mb_convert_encoding( strrev( mb_convert_encoding($string, 'UTF-16BE', 'UTF-8') ), 'UTF-8', 'UTF-16LE');
while ($strlen-- > 0) {
$gnirts .= mb_substr($string, $strlen, 1);
}

return $gnirts;
}

return $string;
}

/*** Polyfills ***/

if (!function_exists('array_column')) {
Expand Down
7 changes: 5 additions & 2 deletions textpattern/publish/taghandlers.php
Expand Up @@ -5403,8 +5403,11 @@ function txp_escape($atts, $thing = '')
$thing = is_int($thing) ? ($thing ? $thing : '') : $attr($thing);
break;
case 'tidy':
$thing = preg_replace('/\s+/', ' ', trim($thing));
$tidy = true;
$thing = preg_replace('/\s+/', ' ', trim($thing));
break;
case 'untidy':
$tidy = false;
break;
case 'textile':
if ($textile === null) {
Expand Down Expand Up @@ -5466,7 +5469,7 @@ function txp_wraptag($atts, $thing = '')
!isset($default) or trim($thing) !== '' or $thing = $default;

if (trim($thing) !== '') {
$thing = $wraptag ? doTag($thing, $wraptag, $class, '', '', $html_id) : $thing;
$thing = $wraptag ? doTag($thing, $wraptag, $class, '', $html_id) : $thing;
$thing = $label ? doLabel($label, $labeltag).n.$thing : $thing;
}

Expand Down

0 comments on commit 21c8e6e

Please sign in to comment.