From 14ef693b2bc50b8447d2055332e0a4f344d7c6ff Mon Sep 17 00:00:00 2001 From: Eduardo Date: Sat, 25 Nov 2023 02:10:59 +0100 Subject: [PATCH] span and a generators are now prepared to handle classes --- page-generator/generator.php | 46 +++++++++++++++++++++++------------- page-generator/index.php | 2 +- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/page-generator/generator.php b/page-generator/generator.php index 6d3ebea..c9a72e7 100644 --- a/page-generator/generator.php +++ b/page-generator/generator.php @@ -94,23 +94,36 @@ class CodeGenerator /** * Returns a string with a span tag with a title set */ - function spanTitle(string $title, string $text): string + function spanTitle(string $title, string $text, array | null $class): string { - return "$text "; + $html = "a($url, $section, $title); + $html .= $this->a($url, $section, $title, $filtered_classes); elseif (empty($text) && !empty($title)) - $html .= $this->spanTitle($title, $section); + $html .= $this->spanTitle($title, $section, $filtered_classes); else $html .= $section; @@ -278,17 +291,18 @@ class CodeGenerator private function form_content(string $text, array $class, string $url, string $title): string { $html = ""; + $filtered_classes = $this->filter_meta_classes($class); // if has title and url = a with title if (!empty($title) && !empty($url)) - $html .= $this->a($url, $text, $title); + $html .= $this->a($url, $text, $title, $filtered_classes); // if has only title = span with title elseif (!empty($title)) { - $html .= $this->spanTitle($title, $text); + $html .= $this->spanTitle($title, $text, $filtered_classes); } // if has only url = a elseif (!empty($url)) - $html .= $this->a($url, $text); + $html .= $this->a($url, $text, null, $filtered_classes); // else just text = p else $html .= $text; @@ -301,7 +315,7 @@ class CodeGenerator if (in_array("no-space", $class)) $html = trim($html); - + return $html; } @@ -317,7 +331,7 @@ class CodeGenerator // if has title and url = a with title if (!empty($title) && !empty($url)) { $html .= '>'; - $html .= $this->a($url, $text, $title); + $html .= $this->a($url, $text, $title, null); } // if has only title = span with title elseif (!empty($title)) { diff --git a/page-generator/index.php b/page-generator/index.php index 4edba1e..5f05955 100644 --- a/page-generator/index.php +++ b/page-generator/index.php @@ -127,7 +127,7 @@ $generator->writeToFile($header_path, '