DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:htag

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:htag [2009-01-25 23:15] 84.51.133.41plugin:htag [2022-01-12 01:18] (current) – Obsolete Klap-in
Line 7: Line 7:
 type       : syntax type       : syntax
 lastupdate : 2007-07-23 lastupdate : 2007-07-23
-compatible : 2007-06-26+compatible : 2013-05-10 2012-10-13 2012-01-25 and 2011-05-25
 depends    :  depends    : 
 conflicts  : numberedheadings conflicts  : numberedheadings
 similar    :  similar    : 
-tags       : headlineheading+tags       : editingheadings,!obsolete #as not maintained, no download available 
 ---- ----
  
Line 20: Line 20:
 ===== Description ===== ===== Description =====
 This is similar to Tony Pujal's @h# hack found in the discussion of the [[tips:reverseheadertags|inverse headings hack]].  It adds an easy-to-read syntax for headings in addition to the wiki's, and as a plugin.  This is my first effort at playing with DokuWiki code, so please point out any mistakes. This is similar to Tony Pujal's @h# hack found in the discussion of the [[tips:reverseheadertags|inverse headings hack]].  It adds an easy-to-read syntax for headings in addition to the wiki's, and as a plugin.  This is my first effort at playing with DokuWiki code, so please point out any mistakes.
- 
 ===== Usage ===== ===== Usage =====
   h1. A Heading to Rule Them All!   h1. A Heading to Rule Them All!
Line 28: Line 27:
 This syntax breaks compatibility with any code or plugins that manipulate the use of ''='''s to mark headings, such as [[plugin:numberedheadings]]. This syntax breaks compatibility with any code or plugins that manipulate the use of ''='''s to mark headings, such as [[plugin:numberedheadings]].
  
-A demo and plugin download will be made available once I finish deploying my wiki ;P+A demo and plugin download will be made available once I finish deploying my wiki ;P FIXME (URL to author's wiki ?)
  
 ===== Installation ===== ===== Installation =====
Line 37: Line 36:
  
 ==== Source Code ==== ==== Source Code ====
-<code php>+<code php syntax.php>
 <?php /** <?php /**
   This plugin provides alternative heading syntax.   This plugin provides alternative heading syntax.
Line 47: Line 46:
   @since      23-Jul-2007   @since      23-Jul-2007
 **/ **/
- 
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 
-require_once(DOKU_PLUGIN.'syntax.php'); 
  
 class syntax_plugin_htag extends DokuWiki_Syntax_Plugin { class syntax_plugin_htag extends DokuWiki_Syntax_Plugin {
Line 61: Line 56:
                         'name' => 'Heading Level Tag',                         'name' => 'Heading Level Tag',
                         'desc' => 'Adds outline-style markup (h1.~) syntax for headings.',                         'desc' => 'Adds outline-style markup (h1.~) syntax for headings.',
-                        'url' => 'http://www.dokuwiki.org/plugin:htag'+                        'url' => 'https://www.dokuwiki.org/plugin:htag'
                 );                 );
         }         }
Line 79: Line 74:
         function getSort() { return 44; }         function getSort() { return 44; }
                  
-        function handle( $match, $state, $pos, &$handler )+        function handle( $match, $state, $pos, Doku_Handler $handler) {
         {         {
                 global $conf;                 global $conf;
Line 87: Line 82:
                 $level = substr( $htag[0], 1, 1 );                 $level = substr( $htag[0], 1, 1 );
  
-                if( $handler->status['section') $handler->_addCall('section_close',array(), $pos);+                if( $handler->getStatus('section') $handler->addCall('section_close',array(), $pos);
                 if( $level <= $conf['maxseclevel'] ) {                 if( $level <= $conf['maxseclevel'] ) {
-                    $handler->_addCall('section_edit',array($handler->status['section_edit_start'], $pos-1, +                    $handler->addCall('section_edit',array($handler->getStatus('section_edit_start'), $pos-1, 
-                                $handler->status['section_edit_level'], $handler->status['section_edit_title']), $pos); +                                $handler->getStatus('section_edit_level'), $handler->getStatus('section_edit_title')), $pos); 
-                    $handler->status['section_edit_start'] = $pos; +                    $handler->setStatus('section_edit_start'$pos)
-                    $handler->status['section_edit_level'] = $level; +                    $handler->setStatus('section_edit_level'$level)
-                    $handler->status['section_edit_title'] = $title;+                    $handler->setStatus('section_edit_title'$title);
                 }                 }
-                $handler->_addCall('header',array($title,$level,$pos), $pos); +                $handler->addCall('header',array($title,$level,$pos), $pos); 
-                $handler->_addCall('section_open',array($level),$pos); +                $handler->addCall('section_open',array($level),$pos); 
-                $handler->status['section'] = true;+                $handler->setStatus('section'true);
  
                 return true;                 return true;
         }         }
  
-        function render( $format, &$renderer, $data )+        function render( $format, Doku_Renderer $renderer, $data) {
         {         {
                 return true;                 return true;
Line 111: Line 106:
  
 ===== Changelog ===== ===== Changelog =====
 +  * **Version ..** 2022: some code cleanup, not tested
   * **Version 0.95 (2007-07-23)**: Fixed no-sections bug.   * **Version 0.95 (2007-07-23)**: Fixed no-sections bug.
   * **Version 0.9 (2007-07-17)**: First published version.   * **Version 0.9 (2007-07-17)**: First published version.
Line 131: Line 127:
 Anyone got any ideas what's causing this? Anyone got any ideas what's causing this?
  
 +==== Error - 10 Feb 2011 ====
 +
 +Causes the error : "Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'Doku_Renderer_metadata::section_edit' was given in /var/www/redmine-wiki/inc/parserutils.php on line 419"
 +on the first load for each page.  Refreshing the page will have it come up clean.  Clearing the cache makes no difference.
 +
 +----
 +
 +**11 Dec 2011** (kaj.wiik ə iki.fi)
 +
 +Edit the following lines out (section edit is done now elsewhere):
 +
 +<code>
 +if( $level <= $conf['maxseclevel'] ) {
 +                    $handler->_addCall('section_edit',array($handler->status['section_edit_start'], $pos-1,
 +                                $handler->status['section_edit_level'], $handler->status['section_edit_title']), $pos);
 +                    $handler->status['section_edit_start'] = $pos;
 +                    $handler->status['section_edit_level'] = $level;
 +                    $handler->status['section_edit_title'] = $title;
 +}
 +</code>
 +  
plugin/htag.1232921745.txt.gz · Last modified: 2009-07-06 19:12 (external edit)

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