Skip to content

Commit

Permalink
tiny fix
Browse files Browse the repository at this point in the history
  • Loading branch information
energy-coresky committed Feb 16, 2025
1 parent 7f0f65a commit a115a22
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 11 additions & 4 deletions w2/md.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function leaf_html($x) {
$x->grab = "</$tag>";
} else {
$tag = strtolower($m[1]);
if ($close = '/' == $tag[0])
if ('/' == $tag[0])
$tag = substr($tag, 1);
$tags = in_array($tag, MD::$MD->tags) && ($m[2] || $m[0] == "<$m[1]");
if ($tags || 1) {
Expand All @@ -50,14 +50,14 @@ private function leaf_html($x) {
return false;
}
}
//$this->close('p');
//$this->use_close($x);
}
//$this->close('p');
//$this->use_close($x);
$blank = '<' == $x->grab;
if ($blank && $x->empty || !$blank && false !== strpos($x->line, $x->grab))
$x->grab = false;
$x->empty or $this->j += strlen($x->line);
return $this->push('-html', $x->line);//, ['c' => 'r']
return $this->push('-html', $x->line);
}

private function leaf_h6($x) {
Expand Down Expand Up @@ -322,6 +322,9 @@ private function line($x) {
} else {
$this->add("\\");// 2do <br>
}
} elseif ('&' == $y && preg_match("/^&[a-z]+;/i", $this->cspn("\n"), $m)) {
$this->push('-', $m[0], ['bg' => '+']);
$j += strlen($m[0]);
} elseif ('<' == $y && preg_match("/^<\/?([a-z_:][\w:\.\-]*)\b[^>]*>/i", $this->cspn("\n"), $m)) {
$this->push('-', $m[0], ['bg' => '+']);
$j += strlen($m[0]);
Expand Down Expand Up @@ -574,6 +577,10 @@ private function set_x($n, $x, &$y = null, &$last = null) {
return $ary;
}

static function html($str) {
return str_replace(['<', '>'], ['&lt;', '&gt;'], $str);
}

private function spn($set, $j = 0, &$sz = null) { # collect $set
return substr($this->in, $j ?: $this->j, $sz = strspn($this->in, $set, $j ?: $this->j));
}
Expand Down
8 changes: 4 additions & 4 deletions w2/show.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static function highlight_md($code, &$bg) { # r g d c m j - gray
$md = new MD($code);
$out = $node = $bg = $html = '';
$hl = '=';
self::$bg['*'] = '#ffa';
$attr = function ($n) use (&$node, $md) {
return $md->attr($node, $n);
};
Expand All @@ -281,11 +282,10 @@ static function highlight_md($code, &$bg) { # r g d c m j - gray
if ('x-code' == $node->name)
$hl = '*';
} elseif (is_string($node->val)) {
if ($cnt = substr_count($node->val, "\n")) {
if ($cnt = substr_count($node->val, "\n"))
$bg .= str_pad('', $cnt, $html ? '+' : ('#skip' == $node->name ? '=' : $hl));
if (is_null($node->right) && !$attr('last'))
$hl = '=';
}
if (is_null($node->right) && !$attr('last'))
$hl = '=';
if ($c = $attr('c')) {
$out .= self::span($c, $node->val);
} elseif ($c = $attr('bg')) {
Expand Down
1 change: 0 additions & 1 deletion w2/xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class XML extends CSS
protected $j = 0;

function __construct(string $in = '', $tab = 2) {
set_time_limit(3);
parent::__construct($in, $tab);
$this->root = XML::node('#root');
XML::$XML or XML::$XML = yml('+ @inc(html)');
Expand Down

0 comments on commit a115a22

Please sign in to comment.