plugin:numberedheadings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
plugin:numberedheadings [2018-02-06 16:41] – [lib/plugins/numberedheadings/syntax.php] Juergen_aus_Zuendorf | plugin:numberedheadings [2022-08-02 20:44] – 188.136.54.48 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== Numbered Headings |
---- plugin ---- | ---- plugin ---- | ||
description: | description: | ||
- | author | + | author |
- | email : dokuwiki@meistermetz.de | + | email : sahara.satoshi@gmail.com |
type : syntax | type : syntax | ||
- | lastupdate : 2010-05-12 | + | lastupdate : 2020-06-14 |
- | compatible : 2013-06-03, 2009-12-25, 2014-09-29 " | + | compatible : 2014-09-29 2015-08-10, 2018-04-22, 2020-07-29 Hogfather, 2022-08-02 Igor |
depends | depends | ||
conflicts | conflicts | ||
Line 13: | Line 13: | ||
tags : style, headings | tags : style, headings | ||
- | downloadurl: | + | downloadurl: |
+ | bugtracker : https:// | ||
+ | sourcerepo : https:// | ||
---- | ---- | ||
===== Installation ===== | ===== Installation ===== | ||
+ | Search and install the plugin using the [[plugin: | ||
- | Download the plugin package and unpack it to your plugin-directory (**lib/ | + | Alternatively, |
- | You may use the following links (at your own risk), these links are provided for convenience to use with the DokuWiki plugin manager: | ||
- | [[http:// | ||
===== Usage ===== | ===== Usage ===== | ||
- | To use this plugin just add a ' | + | Adding |
====== - Level 1 Headline ====== | ====== - Level 1 Headline ====== | ||
===== - Level 2 Headline ===== | ===== - Level 2 Headline ===== | ||
+ | ==== -#5 Level 3 Headline ==== | ||
==== - Level 3 Headline ==== | ==== - Level 3 Headline ==== | ||
+ | ===== -#7 Level 2 Headline ===== | ||
==== - Level 3 Headline ==== | ==== - Level 3 Headline ==== | ||
- | ===== - Level 2 Headline ===== | ||
- | ==== - Level 3 Headline ==== | ||
- | ... | ||
- | The output should then look like this: | ||
- | 1 Level 1 Headline | ||
- | 1.1 Level 2 Headline | ||
- | 1.1.1 Level 3 Headline | ||
- | 1.1.2 Level 3 Headline | ||
- | 1.2 Level 2 Headline | ||
- | 1.2.1 Level 3 Headline | ||
- | ... | ||
+ | When the config **tier1** is set to 2, the headings are interpreted as if you have written: | ||
+ | ====== Level 1 Headline ====== | ||
+ | ===== 1. Level 2 Headline ===== | ||
+ | ==== 1.5 Level 3 Headline ==== | ||
+ | ==== 1.6 Level 3 Headline ==== | ||
+ | ===== 7. Level 2 Headline ===== | ||
+ | ==== 7.1 Level 3 Headline ==== | ||
+ | | ||
+ | === Experimental: | ||
+ | Character variables can be incremented in PHP, like A0, A1, A2 ... You can use '' | ||
- | The user can also set the outline level with the following markup (Thanks to [[martin@idea-games.com|Martin Klima]]): | + | ==== -" |
+ | === - headline === | ||
- | === - #< | ||
- | For example: | + | ===== Configuration ===== |
- | ====== - #3 Level 1 Headline ====== | + | The plugin can be configured within the DokuWiki configuration manager available through the admin menu. |
- | ===== - Level 2 Headline ===== | + | |
- | will be rendered | + | ^ tier1 | heading level corresponding to the 1st tier | default = **2**((As I use a sidebar-index showing the first heading instead of the filename, I configured the plugin to start with the numbered headings from **H2** on. Otherwise the numbers would be shown in the index... but feel free to change the level to **1**.)) | |
+ | ^ format | ||
+ | ^ fancy | styled heading numbers | default = **off** | | ||
- | 3 Level 1 Headline | + | ==== Auto-Detect first-tier level ==== |
- | 3.1 Level 2 Headline | + | |
+ | When the config **tier1** is '' | ||
- | ===== Configuration ===== | + | ==== Numbering format |
- | The plugin can be configured within | + | The config **format** defines tiered numbering style. Each tier format is the formatting string of [[phpfn> |
+ | Some format examples:< | ||
+ | [" | ||
+ | [" | ||
+ | [" | ||
+ | </ | ||
- | ^ startlevel | level to start with numbered headings | default | + | ==== Control numbering feature ==== |
- | ^ tailingdot | show tailing dot after numbers (e.g. 1.2.) | default | + | |
- | The example above generates the following output when '' | + | The numbered headings that are prefixed with "'' |
- | | + | < |
- | 1. Level 2 Headline | + | assume config tier1 is set to 0 |
- | 1.1. Level 3 Headline | + | === --#1000 [" |
- | 1.2. Level 3 Headline | + | === - item 1 === → (1001) item 1 |
- | 2. Level 2 Headline | + | === -- === ... initialize tier1, format, headings counter |
- | 2.1. Level 3 Headline | + | ==== - item 2 ==== → 1. item 2 |
- | ... | + | </ |
- | You can also override the startlevel | + | You can also override the first-tier level in a per-page basis. Just insert this code to your page: |
< | < | ||
- | {{startlevel> | + | ~~HEADLINE NUMBERING FIRST LEVEL = n~~ |
</ | </ | ||
Line 84: | Line 93: | ||
- | ===== Code ===== | + | ===== Development |
- | This is the actual | + | The Numbered Headings plugin was initially developed by [[dokuwiki@meistermetz.de|Lars J. Metz]], and provided provided for convenience to use with the DokuWiki |
+ | [[http:// | ||
- | ==== lib/plugins/numberedheadings/syntax.php ==== | + | Since 2019-01-02, the plugin code has moved to github repository to provide better accessibility for install and further development opportunity. Thanks Lars J. Metz for your early work and encouraging me to move the code to github. |
- | <file php syntax.php> | ||
- | <?php | ||
- | /** | ||
- | * Plugin Numbered Headings: Plugin to add numbered headings to DokuWiki-Syntax | ||
- | * | ||
- | * Usage: | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | * => 1 Heading Level 1 | ||
- | | ||
- | | ||
- | | ||
- | * | ||
- | * @license | ||
- | * @author | ||
- | */ | ||
- | if(!defined(' | + | === Change Log from github repository === |
- | if(!defined(' | + | |
- | require_once(DOKU_PLUGIN.' | + | |
- | class syntax_plugin_numberedheadings extends DokuWiki_Syntax_Plugin | + | {{rss> |
- | // is now set in configuration manager | ||
- | var $startlevel = 0; // level to start with numbered headings (default = 2) | ||
- | var $tailingdot = 0; // show a tailing dot after numbers (default = 0) | ||
- | var $levels = array( ' | + | === Old Revision List === |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | + | ||
- | var $headingCount = | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | function syntax_plugin_numberedheadings() { | + | |
- | $this-> | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | function getInfo(){ | + | |
- | return array( ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | ' | + | |
- | } | + | |
- | + | ||
- | function getType(){ | + | |
- | return ' | + | |
- | } | + | |
- | + | ||
- | function connectTo($mode) { | + | |
- | $this-> | + | |
- | | + | |
- | ' | + | |
- | // added new parameter (matches the parameter name for better recognition) | + | |
- | $this-> | + | |
- | | + | |
- | ' | + | |
- | $this-> | + | |
- | | + | |
- | ' | + | |
- | } | + | |
- | + | ||
- | function getSort() { | + | |
- | return 45; | + | |
- | } | + | |
- | + | ||
- | function handle($match, | + | |
- | + | ||
- | // obtain the startlevel from the page if defined | + | |
- | if (preg_match('/ | + | |
- | $this-> | + | |
- | return true; | + | |
- | } | + | |
- | + | ||
- | // define the level of the heading | + | |
- | preg_match('/ | + | |
- | $level = $this-> | + | |
- | + | ||
- | // obtain the startnumber if defined | + | |
- | if (preg_match('/# | + | |
- | $this-> | + | |
- | + | ||
- | //delete the startnumber-setting markup from string | + | |
- | $match = preg_replace('/# | + | |
- | + | ||
- | } else { | + | |
- | + | ||
- | // increment the number of the heading | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | // build the actual number | + | |
- | $headingNumber = ''; | + | |
- | for ($i=$this-> | + | |
- | + | ||
- | // reset the number of the subheadings | + | |
- | if ($i> | + | |
- | $this-> | + | |
- | } | + | |
- | + | ||
- | // build the number of the heading | + | |
- | $headingNumber .= ($this-> | + | |
- | } | + | |
- | + | ||
- | // delete the tailing dot if wished (default) | + | |
- | $headingNumber = ($this-> | + | |
- | + | ||
- | // insert the number... | + | |
- | $match = preg_replace('/ | + | |
- | + | ||
- | // ... and return to original behavior | + | |
- | $handler-> | + | |
- | + | ||
- | return true; | + | |
- | } | + | |
- | + | ||
- | function render($format, | + | |
- | //do nothing (already done by original render-method) | + | |
- | } | + | |
- | } | + | |
- | //Setup VIM: ex: et ts=4 enc=utf-8 :</ | + | |
- | + | ||
- | + | ||
- | --- [[user> | + | |
- | -> Changes for compatibility to PHP7: \\ | + | |
- | "& | + | |
- | ==== lib/ | + | |
- | + | ||
- | <file php default.php> | + | |
- | <?php | + | |
- | /** | + | |
- | * Options for the NumberedHeading Plugin | + | |
- | * | + | |
- | * @author | + | |
- | */ | + | |
- | + | ||
- | $conf[' | + | |
- | $conf[' | + | |
- | </ | + | |
- | + | ||
- | ==== lib/ | + | |
- | + | ||
- | <file php metadata.php> | + | |
- | <?php | + | |
- | /** | + | |
- | * Metadata for the NumberedHeading Plugin | + | |
- | * | + | |
- | * @author | + | |
- | */ | + | |
- | + | ||
- | $meta[' | + | |
- | $meta[' | + | |
- | </ | + | |
- | + | ||
- | ==== lib/ | + | |
- | + | ||
- | <file php settings.php> | + | |
- | <?php | + | |
- | /** | + | |
- | * German language file | + | |
- | * | + | |
- | * @author | + | |
- | */ | + | |
- | + | ||
- | // for the configuration manager | + | |
- | $lang[' | + | |
- | $lang[' | + | |
- | </ | + | |
- | + | ||
- | ==== lib/ | + | |
- | + | ||
- | <file php settings.php> | + | |
- | <?php | + | |
- | /** | + | |
- | * English language file | + | |
- | * | + | |
- | * @author | + | |
- | */ | + | |
- | + | ||
- | // for the configuration manager | + | |
- | $lang[' | + | |
- | $lang[' | + | |
- | </ | + | |
- | + | ||
- | ===== Revision List ===== | + | |
* 2006-08-25 --- Published Plugin | * 2006-08-25 --- Published Plugin | ||
Line 291: | Line 112: | ||
* 2010-05-11 --- Added the availability to show a tailingdot | * 2010-05-11 --- Added the availability to show a tailingdot | ||
* 2010-05-12 --- Brought '' | * 2010-05-12 --- Brought '' | ||
+ | * 2019-01-02 --- Added new macro to set startlevel in a page | ||
+ | * 2019-01-03 --- Allow css for tiered numbers in headings | ||
- | ===== Discussion | + | ===== Tips ===== |
- | Feel free to make any comments regarding my plugin... or write me an email ([[dokuwiki@meistermetz.de|Lars J. Metz]]). | + | For your information: |
- | This is so basic, it should be in the basic installation of DokuWiki IMHO... diftong@gmx.net | + | ---- |
- | Would be good to bring the start level out to configuration. | ||
- | > Done. --- // | + | ===== Old Discussion ===== |
- | + | ||
- | ---- | + | |
Could a similar system be used to format the numbered lists in nested decimal style instead of the crazy roman numerals and stuff? Better with just changing the css maybe? If so any ideas how best to do that? Armin. | Could a similar system be used to format the numbered lists in nested decimal style instead of the crazy roman numerals and stuff? Better with just changing the css maybe? If so any ideas how best to do that? Armin. | ||
---- | ---- | ||
- | |||
Great thing, just what I was looking for, there is just one issue in combination with page-includes ([[plugin: | Great thing, just what I was looking for, there is just one issue in combination with page-includes ([[plugin: | ||
Line 325: | Line 144: | ||
---- | ---- | ||
- | For your information: | + | Seems like the changes in Rincewind metadata handling means that the numbering sometimes doesn' |
---- | ---- | ||
- | ** Per page start level ** | + | ==== Per page start level ==== |
I've just merged the code for adding the ability to set the startlevel in a per-page basis. Just added the first line of '' | I've just merged the code for adding the ability to set the startlevel in a per-page basis. Just added the first line of '' | ||
- | + | Also, added the instructions for using. --- // | |
- | Also, added the instructions for using. | + | |
- | + | ||
- | --- // | + | |
> Thanks | > Thanks | ||
---- | ---- | ||
+ | |||
+ | ==== Set outline level for each heading ==== | ||
I have added the ability for the user to set the outline level with the following markup: | I have added the ability for the user to set the outline level with the following markup: | ||
Line 360: | Line 178: | ||
---- | ---- | ||
+ | |||
+ | ==== Css for heading numbers ==== | ||
+ | |||
+ | **Fantastic plugin!** I was wondering if anyone knows what I would need to modify to add tags like < | ||
+ | |||
+ | I have tried messing with the code myself, but any html I add shows as text, and not interpreted as real html code. Could anyone figure this out? - // [[kououken@gmail.com|kououken]] 2012/02/07 14:32 // | ||
+ | |||
+ | ---- | ||
+ | ===== Suggestion / Request ===== | ||
+ | |||
+ | > **Great plugin** | ||
+ | > - Include an option by wiki, to do this automatically (without the hyphens) for all pages | ||
+ | > - Disable option by page, when enabled at wiki level | ||
+ | > - Enable the option by page by a setting at the top of the page | ||
+ | > | ||
+ | > Thanks! | ||
+ | |||
+ | I just developed this feature for my own needs. The code is available from [[https:// | ||
+ | * an option to enable numbering by default on every page | ||
+ | * the possibility to use ''< | ||
+ | |||
+ | |||
+ | ==== Start pages with sub level ==== | ||
+ | |||
+ | I would like to break up longer pages into subpages. These new pages then should to start numbering at a sub level. | ||
+ | |||
+ | For example: | ||
+ | |||
+ | ====== - #3.1 Level 1 Headline ====== | ||
+ | ===== - Level 2 Headline ===== | ||
+ | |||
+ | should be rendered as: | ||
+ | |||
+ | 3.1 Level 1 Headline | ||
+ | 3.1.1 Level 2 Headline | ||
+ | |||
+ | What changes to '' | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== More flexible numbering ==== | ||
Some modification. For example: | Some modification. For example: | ||
Line 398: | Line 257: | ||
--- // | --- // | ||
- | ---- | ||
- | Seems like the changes in Rincewind metadata handling means that the numbering sometimes doesn' | ||
- | |||
- | ---- | ||
- | |||
- | **Fantastic plugin!** I was wondering if anyone knows what I would need to modify to add tags like < | ||
- | |||
- | I have tried messing with the code myself, but any html I add shows as text, and not interpreted as real html code. Could anyone figure this out? - // [[kououken@gmail.com|kououken]] 2012/02/07 14:32 // | ||
- | |||
- | ---- | ||
- | ===== Suggestion / Request ===== | ||
- | > **Great plugin** | ||
- | > - Include an option by wiki, to do this automatically (without the hyphens) for all pages | ||
- | > - Disable option by page, when enabled at wiki level | ||
- | > - Enable the option by page by a setting at the top of the page | ||
- | > | ||
- | > Thanks! | ||
- | |||
- | I just developed this feature for my own needs. The code is available for download [[https:// | ||
- | * an option to enable numbering by default on every page | ||
- | * the possibility to use ''< |
plugin/numberedheadings.txt · Last modified: 2023-09-13 08:34 by s-sahara