private function form_list(string $text, array $class, string $url, string $title): string
{
- $html = "<li";
+ // if in class array is not "same-line" set flag
+ if (!in_array("same-line", $class))
+ $this->is_li_same_line = false;
+ else
+ $this->is_li_same_line = true;
+
+ if (isset($this->was_li_same_line) && !$this->was_li_same_line)
+ $html = "<li";
+ else
+ $html = "";
// if class not empty add class
$filtered_classes = $this->filter_meta_classes($class);
$html .= ' class="' . implode(' ', $filtered_classes) . '"';
// if has title and url = a with title
- if (!empty($title) && !empty($url)) {
- $html .= '>';
- $html .= $this->a($url, $text, $title, null);
+ if (!empty($url)) {
+ if (!$this->was_li_same_line)
+ $html .= '>';
+ $html .= $this->a($url, $text, $title, $filtered_classes);
+
+ if (in_array("no-space", $class))
+ $html = trim($html);
}
// if has only title = span with title
elseif (!empty($title)) {
$html .= " title='$title'>$text";
- } else
- $html .= ">$text";
+ } else {
+ if (isset($this->was_li_same_line) && !$this->was_li_same_line)
+ $html .= '>';
+ $html .= "$text";
+ }
- $html .= "</li>";
+ if (!$this->is_li_same_line)
+ $html .= '</li>';
+ $this->was_li_same_line = $this->is_li_same_line;
return $html;
}