mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-25 14:34:36 +00:00
Make lexicon.php parse Patchouli codes (#3074)
This commit is contained in:
1 parent
dac02cccd6
commit
6dbb46ee22
1 file changed
+19
-6
+19
-6
@@ -14,6 +14,19 @@
|
||||
<?php
|
||||
$file = file_get_contents('https://raw.githubusercontent.com/Vazkii/Botania/master/src/main/resources/assets/botania/lang/en_us.json');
|
||||
$json = json_decode($file, true);
|
||||
$default_keys = [
|
||||
'botania_corporea_request' => 'c',
|
||||
'curios.open.desc' => 'k',
|
||||
'left' => 'a',
|
||||
'right' => 'w',
|
||||
'sprint' => 'CTRL'
|
||||
];
|
||||
$replacements = array_merge(array_combine(array_map("quote_keys", array_keys($default_keys)), array_values($default_keys)), [
|
||||
'/\$\((br|p)\)/' => "<br />",
|
||||
'/\$\(li\)/' => " • ",
|
||||
'/\$\(([0-9a-o])\)([^$]+)(?:\$\([0r]?\)|(?=<)|$)/' => "<span class='mc-color-$1'>$2</span>",
|
||||
'/\$\(l:([^)]+)\)([^$]+)\$\(\/l\)/' => "<a href='$1'>$2</a>"
|
||||
]);
|
||||
|
||||
$opened_div = false;
|
||||
|
||||
@@ -21,20 +34,17 @@
|
||||
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('</div>');
|
||||
|
||||
echo("<br><a href='#$current_entry' class='entry-bookmark glyphicon glyphicon-bookmark' title='Permalink'></a> <b id='$current_entry-fake'>$value</b><div class='entry-text'>");
|
||||
echo("\n");
|
||||
$opened_div = true;
|
||||
}
|
||||
|
||||
if(sizeof($page_match) > 0) {
|
||||
$page = preg_replace('/&(.)((?:[^&])+)(?:(?:&(?:0|r))|$)/', "<span class='mc-color-$1'>$2</span>", $value) . '<br>';
|
||||
$no_control = preg_replace('/&./', '', $value);
|
||||
$page = preg_replace(array_keys($replacements), array_values($replacements), $value) . '<br />';
|
||||
$no_control = preg_replace('/\$\(.\)/', '', $value);
|
||||
if(strlen($no_control) > 50) {
|
||||
echo($page);
|
||||
echo("\n");
|
||||
@@ -57,4 +67,7 @@
|
||||
function match_page($key, $entry_name) {
|
||||
return match("botania\.page\.$entry_name\d+", $key);
|
||||
}
|
||||
?>
|
||||
function quote_keys($key) {
|
||||
return "/\\$\\(k:$key\\)/";
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user