DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:hiddenheader

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:hiddenheader [2017-11-07 03:16] 68.186.200.178plugin:hiddenheader [2024-02-11 03:40] (current) zioth
Line 6: Line 6:
 email      : elifenton@this_is_not_a_real_email.fake email      : elifenton@this_is_not_a_real_email.fake
 type       : action type       : action
-lastupdate : 2013-05-22 +lastupdate : 2024-02-10 
-compatible : angua, rincewind, weatherwax, binky, ponder stibbons, hrun, detritus, Frusterick Manners+compatible : angua, rincewind, weatherwax, binky, ponder stibbons, hrun, detritus, Frusterick Manners, greebo, Hogfather, Igor, Jack Jackrum, Kaos
 depends    :  depends    : 
 conflicts  conflicts 
Line 13: Line 13:
 tags       : section, header, include, title tags       : section, header, include, title
  
-downloadurl: # eg. https://github.com/zioth/dokuwiki-plugin-hiddenheader/zipball/master +downloadurl: https://github.com/zioth/dokuwiki_hiddenheader/archive/master.zip 
-bugtracker : # eg. https://github.com/zioth/dokuwiki-plugin-hiddenheader/issues +bugtracker : https://github.com/zioth/dokuwiki_hiddenheader/issues 
-sourcerepo : # eg. https://github.com/zioth/dokuwiki-plugin-hiddenheader/+sourcerepo : https://github.com/zioth/dokuwiki_hiddenheader
 donationurl:  donationurl: 
 ---- ----
Line 22: Line 22:
  
 I made this as a companion to the [[plugin:include|include plugin]]. Include lets you include a page or a section, but it's missing a feature I consider very useful -- the ability to include an excerpt from a large document which is not annotated with section headers. I made this as a companion to the [[plugin:include|include plugin]]. Include lets you include a page or a section, but it's missing a feature I consider very useful -- the ability to include an excerpt from a large document which is not annotated with section headers.
- 
- 
-===== Installation ===== 
- 
-I haven't bothered to make this plugin downloadable. Just copy and paste the following into /lib/plugins/hiddenheader/action.php. 
- 
-<code php lib/plugins/hiddenheader/action.php> 
-<?php 
-/** 
- * hiddenheader Plugin for DokuWiki / action.php 
- * 
- * @license GPL - http://www.gnu.org/copyleft/gpl.html 
- * @author  Eli Fenton 
- */ 
- 
-if (!defined('DOKU_INC')) {die();} 
-if (!defined('DOKU_PLUGIN')) {define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');} 
-require_once DOKU_PLUGIN . 'action.php'; 
- 
-class action_plugin_hiddenheader extends DokuWiki_Action_Plugin { 
-    function getInfo() {return array('author' => 'Eli Fenton', 'name' => 'Hidden Header Plugin', 'url' => 'http://dokuwiki.org/plugin:hiddenheader');} 
- 
-    function register(Doku_Event_Handler $controller) { 
-        $controller->register_hook('PARSER_WIKITEXT_PREPROCESS', 'AFTER', $this, 'handlePreprocess'); 
-        $controller->register_hook('RENDERER_CONTENT_POSTPROCESS', 'BEFORE', $this, 'handlePostProcess'); 
-        $controller->register_hook('TPL_TOC_RENDER', 'BEFORE', $this, 'handleToc'); 
-    } 
- 
-    function handlePreprocess(&$event, $param) { 
-        // should accumulate in hash 
-        if ($this->hidden) 
-                return; 
-        preg_match_all('/==+\%hide\s*([^=]+)/', $event->data, $m); 
-        $this->hidden = $m && count($m[1])>0 ? $m[1] : null; 
- 
-        if ($this->hidden) 
-            $event->data = preg_replace('/(==+)\%hide/', '$1', $event->data); 
-    } 
- 
-    function handlePostProcess(&$event, $param) { 
-        if ($this->hidden) 
-                foreach ($this->hidden as $h) { 
-                        $event->data[1] = preg_replace('/<h\d[^>]*>(<a name[^>]*>|)'.trim($h).'(<\/a>|)<\/h\d>/', '$1$2', $event->data[1]); 
-        } 
-    } 
- 
-    function handleToc(&$event, $param) { 
-        if ($this->hidden) { 
-            $map = array(); 
-            foreach ($this->hidden as $h) 
-                $map[trim($h)] = 1; 
-            $newdata = array(); 
-            foreach ($event->data as $d) { 
-                if (!$map[$d['hid']]) 
-                    $newdata[] = $d; 
-            } 
-            // I don't know what's special about the number "2." There must be two hidden elements or something. 
-            $event->data = count($newdata)<=2 ? array() : $newdata; 
-        } 
-    } 
- 
-    var $hidden; 
-} 
-</code> 
  
  
Line 125: Line 61:
  
 ==Change Log== ==Change Log==
 +  * 2018-12-31: Fixed some long-standing bugs.
   * 2013-05-22: Updated for Weatherwax. The new DokuWiki doesn't add anchors to headers unless there's a TOC.   * 2013-05-22: Updated for Weatherwax. The new DokuWiki doesn't add anchors to headers unless there's a TOC.
   * 2012-03-29: I just ran into a case where the preprocess command could be called twice by dokuwiki. This might be a bug in Angua. The new code works around this problem.   * 2012-03-29: I just ran into a case where the preprocess command could be called twice by dokuwiki. This might be a bug in Angua. The new code works around this problem.
plugin/hiddenheader.1510020972.txt.gz · Last modified: 2017-11-07 03:16 by 68.186.200.178

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki