Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
Learn about DokuWiki
Advanced Use
Corporate Use
Our Community
Follow us on Facebook, Twitter and other social networks.
This is an old revision of the document!
Compatible with DokuWiki
2007-06-26
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Author | Adam B. Ross |
---|---|
Version | 0.95 (2007-07-23) |
DokuWiki version | Tested on v.2007-06-26 |
This is similar to Tony Pujal's @h# hack found in the discussion of the 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.
h1. A Heading to Rule Them All!
This plugin will convert h1.
through h6.
to the equivalent headings. It is not case sensitive, but does need to be marked at the start of the line.
This syntax breaks compatibility with any code or plugins that manipulate the use of =
's to mark headings, such as numberedheadings.
A demo and plugin download will be made available once I finish deploying my wiki ;P
dokuwiki/lib/plugins/htag
.syntax.php
.<?php /** * This plugin provides alternative heading syntax. * It converts h1. to h6. to the DokuWiki headings * * @author Adam B. Ross <abr.programmer@gmail.com> * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @version htag syntax plugin, v0.9 * @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 { function getInfo() { return array ( 'author' => 'Adam B. Ross', 'email' => 'grayside@gmail.com', 'date' => '2007-07-23', 'name' => 'Heading Level Tag', 'desc' => 'Adds outline-style markup (h1.~) syntax for headings.', 'url' => 'http://www.dokuwiki.org/plugin:htag' ); } // header specific function getType() { return 'baseonly'; } // headings shouldn't be parsed.. function accepts($mode) { return false; } function connectTo( $mode ) { $this->Lexer->addSpecialPattern( '^[hH][1-6]\.[ \t]*[^\n]+(?=\n)', $mode, 'plugin_htag' ); } // Doku_Parser_Mode 60 // header (numbered headers) 45 function getSort() { return 44; } function handle( $match, $state, $pos, &$handler ) { global $conf; preg_match( '/^h\d/i', $match, $htag ); $title = substr( $match, 3 ); $title = trim($title); $level = substr( $htag[0], 1, 1 ); if( $handler->status['section'] ) $handler->_addCall('section_close',array(), $pos); 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; } $handler->_addCall('header',array($title,$level,$pos), $pos); $handler->_addCall('section_open',array($level),$pos); $handler->status['section'] = true; return true; } function render( $format, &$renderer, $data ) { return true; } }
If I create a pair of headers:
h1. Heading 1 h2. Heading 2
and then export the page using the odt plugin, then I get spurious blank lines between the headings.
Looking at the content.xml file I can see that these are due to <text:p text:style-name="Text_20_body"/> tags.
However, odt exports ok if the regular heading formats are used.
Anyone got any ideas what's causing this?