bookmark plugin by Otto Vainio
Insert a link anchor into the page
Last updated on 2005-08-01. Provides Syntax.
No compatibility info given!
With this plugin you can insert a bookmark to your page. The format is
<BOOKMARK:name>
This will insert code
<a name='name'></a>
Install with Plugin Manager from here
Create a new folder lib/plugin/bookmark/ and place the following file in it: syntax.php.
lib/plugin/bookmark/syntax.php:
<?php /** * Plugin bookmark: Creates a bookmark to your document. * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Otto Vainio <bookmark.plugin@valjakko.net> */ 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'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_bookmark extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Otto Vainio', 'email' => 'bookmark.plugin@valjakko.net', 'date' => '2005-08-01', 'name' => 'Bookmark plugin', 'desc' => 'a bookmark <a name=\'name\'></a>', 'url' => 'http://www.dokuwiki.org/wiki:plugins', ); } /** * What kind of syntax are we? */ function getType(){ return 'substition'; } function getSort(){ return 357; } function connectTo($mode) { $this->Lexer->addSpecialPattern('<BOOKMARK:\w+>',$mode,'plugin_bookmark'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ $match = substr($match,10,-1); //strip <BOOKMARK: from start and > from end return array(strtolower($match)); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $renderer->doc .= '<a name="' . $data[0] . '" id="' . $data[0]. '"></a>'; return true; } return false; } } ?>
I Installed this plugin, but this script didn't work. I tried to use the syntax but it wans't work. Is there any manual or samples about this plugin?
Hi. Remember to use capital letters for BOOKMARK. So the format is
<BOOKMARK:name>
With the < and > marks. <bookmark:name> will not work… sorry
— Otto Vainio 2006-09-04 12:08
While it works nicely with Firefox, it does not work for me with MSIE 6.0.2800.1106CO SP1, unless is hack the syntax.php to add an id attribute alongside to the name attribute of the anchor tag:
<a name='name' id='name'></a>
Yes I know that MSIE sucks, but DokuWiki uses the same trick for the anchor tags automatically generated for headings… — Gábor Ziegler 2007/06/15 10:01
Hi ! I just love this plugin. But I failed to address one of this bookmarks from within the wiki ?
[[page#bookmark]]
Does not work …
Markus A. Engelkamp
Hi,
Is it possible to use this plugin to point to a particular section of the page?
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported