mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Add automatic heading id if you don't specify one
This commit is contained in:
parent
a0d28c280f
commit
bdd2449ab5
3 changed files with 50 additions and 10 deletions
|
@ -16,6 +16,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
|||
- Added mega-menu support to the `nav_links_extra` setting - the default value for the `nav_links_extra` setting has now changed (delete/rename it in your `peppermint.json` file to get the new version)
|
||||
- An object can now be used to define groups of items in the more menu
|
||||
- Hopefully it now looks less cluttered :P
|
||||
- Headings now have an automatic id if you don't specify one (part of #141)
|
||||
|
||||
### Fixed
|
||||
- Fixed a bug in the search query performance metrics
|
||||
|
|
|
@ -82,10 +82,10 @@
|
|||
{
|
||||
"id": "feature-guiconfig",
|
||||
"name": "Settings GUI",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "The module everyone has been waiting for! Adds a web based gui that lets mods change the wiki settings.",
|
||||
"lastupdate": 1571530165,
|
||||
"lastupdate": 1571583667,
|
||||
"optional": false,
|
||||
"extra_data": []
|
||||
},
|
||||
|
@ -152,10 +152,10 @@
|
|||
{
|
||||
"id": "feature-theme-gallery",
|
||||
"name": "Theme Gallery",
|
||||
"version": "0.3",
|
||||
"version": "0.4",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a theme gallery page and optional automatic theme updates. Contacts a remote server, where IP addresses are stored in automatic server logs for security and attack mitigation purposes.",
|
||||
"lastupdate": 1571531070,
|
||||
"lastupdate": 1571583643,
|
||||
"optional": false,
|
||||
"extra_data": []
|
||||
},
|
||||
|
@ -337,7 +337,7 @@
|
|||
"version": "0.10",
|
||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation.",
|
||||
"lastupdate": 1569062035,
|
||||
"lastupdate": 1571586164,
|
||||
"optional": false,
|
||||
"extra_data": {
|
||||
"Parsedown.php": "https:\/\/raw.githubusercontent.com\/erusev\/parsedown\/fe7a50eceb4a3c867cc9fa9c0aa906b1067d1955\/Parsedown.php",
|
||||
|
|
|
@ -774,8 +774,7 @@ class PeppermintParsedown extends ParsedownExtreme
|
|||
|
||||
// ~
|
||||
|
||||
if($imageCaption)
|
||||
{
|
||||
if($imageCaption) {
|
||||
$rawStyle = $result["element"]["text"][0]["attributes"]["style"];
|
||||
$containerStyle = preg_replace('/^.*float/', "float", $rawStyle);
|
||||
$mediaStyle = preg_replace('/\s*float.*;/', "", $rawStyle);
|
||||
|
@ -799,6 +798,41 @@ class PeppermintParsedown extends ParsedownExtreme
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ██ ██ ███████ █████ ██████ ███████ ██████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ███████ █████ ███████ ██ ██ █████ ██████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ██ ███████ ██ ██ ██████ ███████ ██ ██
|
||||
*/
|
||||
|
||||
private $headingIdsUsed = [];
|
||||
|
||||
protected function blockHeader($line) {
|
||||
// This function overrides the header function defined in ParsedownExtra
|
||||
$result = parent::blockHeader($line);
|
||||
|
||||
// If this heading doesn't have an id already, add an automatic one
|
||||
if(!isset($result["element"]["attributes"]["id"])) {
|
||||
$heading_id = str_replace(" ", "-",
|
||||
mb_strtolower(makepathsafe(
|
||||
$result["element"]["handler"]["argument"]
|
||||
))
|
||||
);
|
||||
$suffix = "";
|
||||
while(in_array($heading_id . $suffix, $this->headingIdsUsed)) {
|
||||
$heading_number = intval(str_replace("_", "", $suffix));
|
||||
if($heading_number == 0) $heading_number++;
|
||||
$suffix = "_" . ($heading_number + 1);
|
||||
}
|
||||
$result["element"]["attributes"]["id"] = $heading_id . $suffix;
|
||||
$this->headingIdsUsed[] = $result["element"]["attributes"]["id"];
|
||||
}
|
||||
|
||||
error_log("[header info] " . var_export($result, true));
|
||||
return $result;
|
||||
}
|
||||
|
||||
# ~
|
||||
# Static Methods
|
||||
# ~
|
||||
|
@ -840,9 +874,14 @@ class PeppermintParsedown extends ParsedownExtreme
|
|||
return $result;
|
||||
}
|
||||
|
||||
# ~
|
||||
# Utility Methods
|
||||
# ~
|
||||
|
||||
/*
|
||||
* ██ ██ ████████ ██ ██ ██ ████████ ██ ███████ ███████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ █████ ███████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██████ ██ ██ ███████ ██ ██ ██ ███████ ███████
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns whether a string is a valid float: XXXXXX; value.
|
||||
|
|
Loading…
Reference in a new issue