prevent var being null
authorEduardo <[email protected]>
Sun, 10 Dec 2023 13:55:37 +0000 (14:55 +0100)
committerEduardo <[email protected]>
Sun, 10 Dec 2023 13:55:37 +0000 (14:55 +0100)
page-generator/generator.php

index 191ed06d7ab43c1ed9d353151ad40f7ca4cbd884..03c583ed6ca0681b61133f5991c0ba7f0552443e 100644 (file)
@@ -198,7 +198,7 @@ class CodeGenerator
         $html = "";
 
         // if previous iteration was diferent section or is first iteration and new section is not empty add h2
-        if (($currentIndex != 0 && $data[$currentIndex - 1]['section'] != $section) || ($currentIndex == 0 && !empty($section))) {
+        if (($currentIndex != 0 && $this->str_val_or_empty($data[$currentIndex - 1], 'section') != $section) || ($currentIndex == 0 && !empty($section))) {
             $html .= '<h2';
             // if text is empty add class, title and url
             $filtered_classes = $this->filter_meta_classes($class);
@@ -478,7 +478,7 @@ class CodeGenerator
             switch ($class) {
                 case in_array("list", $class):
                     // if previous iteration was diferent section close li
-                    if ($i != 0 && $data[$i - 1]['section'] != $section) {
+                    if ($i != 0 && $this->str_val_or_empty($data[$i - 1], 'section') != $section) {
                         [$closing_tag, $is_list_closed] = $this->open_or_close_ul($is_list_closed, $class, CLOSE, $text);
                         $html .= $closing_tag;
                     }
@@ -503,7 +503,7 @@ class CodeGenerator
 
                 default:
                     // if previous iteration was diferent section close p
-                    if ($i != 0 && $data[$i - 1]['section'] != $section) {
+                    if ($i != 0 && $this->str_val_or_empty($data[$i - 1], 'section') != $section) {
                         [$closing_tag, $is_p_closed] = $this->open_or_close_p($is_p_closed, $class, CLOSE);
                         $html .= $closing_tag;