pseudomarkdown_patrones = [
"cabecera" => ['/^(\#{1,6})([^\r\n]+)$/m', fn($campos) => '
' . $this->montar_pseudomarkdown($campos[0][0], self::PARRAFO) . '
'] ]; while(preg_match('/<\!\-{2}\s*\[{2}([^\[\]]+)\]{2}(\s*\-{2}>)?/', $modulos_html, $matches, \PREG_OFFSET_CAPTURE)){ $clave = trim($matches[1][0]); if(preg_match('/<\!\-{2}\s*\[{2}\s*' . $clave . '\s*\]{2}(\s*\-{2}>)?/', $modulos_html = substr($modulos_html, $matches[0][1] + strlen($matches[0][0])), $matches, \PREG_OFFSET_CAPTURE)){ $modulos[$clave] = substr($modulos_html, 0, $matches[0][1]); $modulos_html = substr($modulos_html, $matches[0][1] + strlen($matches[0][0])); }; }; echo self::string_variables($html, [ "menu" => implode("", array_map(fn($campos) => self::string_variables($modulos["elemento_menu_principal"], [ "i18n" => $campos[0], "texto" => $campos[1], "link" => $campos[2], "target" => $campos[3], "icono" => $campos[4] ]), [ ["mapeate_oficial", "Mapeate - Web oficial", "https://mapeate.k3y.pw/", "_self", "mapeate"], ["web_app_oficial", "Mapeate - Aplicación Web oficial", "https://mapeate.k3y.pw/app.html", "_self", "mapeate"], ["mapeate_git", "Mapeate - Git", "https://git.k3y.pw/CaritasSantaCruz/Mapeate", "_blank", "git"], ["caritas_santa_cruz_facebook", "Cáritas Santa Cruz - Facebook", "https://www.facebook.com/santacruzcaritas/", "_blank", "facebook"], ["caritas_santa_cruz_wix", "Cáritas Santa Cruz - Wix", "https://santacruzdecanido.wixsite.com/caritas", "_blank", "wix"], ["caritas_santa_cruz_twitter", "Cáritas Santa Cruz - Twitter", "https://twitter.com/CanidoSantaCruz", "_blank", "twitter"], ["caritas_santa_cruz_fan_web", "Cáritas Santa Cruz - Fan Web", "https://fanwebcaritassantacruz.k3y.pw/", "_blank", "fan_web"] ])), "contenido" => $this->montar_pseudomarkdown(file_get_contents(__DIR__ . "/../HTML/contenido.md")) ]); } public static function string_variables($string, $variables){ return preg_replace_callback('/\{([^\{\}]+)\}/', function($valor) use($variables){ if(isset($variables[$valor[1]])) return $variables[$valor[1]]; return $valor[0]; }, $string); } private function montar_lista($campos){ $lineas = preg_split('/[\r\n]+/', $campos); $html = ''; $niveles = [[0, "ul"]]; $l = 0; foreach($lineas as $linea){ if(!preg_match('/^(\s*)?(\-|[0-9]+\.)?(.*)$/', $linea, $matches)) continue; $separador = strlen($matches[1]); $tipo = $matches[2]; $entrada = $this->montar_pseudomarkdown(trim($matches[3]), self::PARRAFO); if($tipo){ if($niveles[$l][0] == $separador) $html .= ($html ? '' : '<' . ($niveles[$l][1] = $tipo == "-" ? "ul" : "ol") . '>') . '