Lexica Botania Online
'c', 'curios.open.desc' => 'k', 'left' => 'a', 'right' => 'w', 'sprint' => 'CTRL' ]; $entry_cache = array(); $replacements = [ '/\$\((br|p)\)/' => "
", '/\$\(li\)/' => " • ", '/\$\(([1-9a-o])\)([^$]+)(?:\$\([0r]?\)|(?=<)|$)/' => "$2", '/\$\(thing\)([^$]+)(?:\$\([0r]?\)|(?=<)|$)/' => "$1", '/\$\(item\)([^$]+)(?:\$\([0r]?\)|(?=<)|$)/' => "$1", ]; $opened_div = false; $current_entry = ''; foreach($json as $key => $value) { $entry_match = match_entry($key); $page_match = match_page($key, $current_entry); if(sizeof($entry_match) > 0) { $current_entry = $entry_match[1]; if($opened_div) echo(''); echo("
$value
"); echo("\n"); $opened_div = true; } if(sizeof($page_match) > 0) { $page = preg_replace_callback('/\$\(k:([^)]*)\)/', 'key_resolve', preg_replace_callback('/\$\(l:([^)]+)\)([^$]+)\$\(\/l\)/', 'link_resolve', preg_replace(array_keys($replacements), array_values($replacements), $value))) . '
'; $no_control = preg_replace('/\$\(.\)/', '', $value); if(strlen($no_control) > 50) { echo($page); echo("\n"); } } } echo('
'); function match($regex, $line) { $matches = array(); preg_match("/$regex/", $line, $matches); return $matches; } function match_entry($key) { return match('botania\.entry\.(\w+)', $key); } function match_page($key, $entry_name) { return match("botania\.page\.$entry_name\d+", $key); } function key_resolve($match) { global $default_keys; // i'm sorry, i don't know php return (array_key_exists($match[1], $default_keys) ? $default_keys[$match[1]] : "UNKNOWN KEY"); } function link_resolve($match) { $link = $match[1]; $res = []; if(preg_match('|^\w+/(\w+)$|', $link, $res)) { $entry_name = preg_replace_callback('/_(\w)/', function($repl) { return strtoupper($repl[1]); }, $res[1]); $link = "#$entry_name-fake"; } return "$match[2]"; } ?>