DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:anchor

This is an old revision of the document!


Anchor Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" unknown
  • 2022-07-31 "Igor" unknown
  • 2020-07-29 "Hogfather" no

plugin Add HTML anchors to a page. Useful when section headers are really long

Last updated on
2018-12-20
Provides
Syntax
Repository
Source
Conflicts with
diagrams

Similar to bookmark, maplink, wrap

Tagged with anchor, bookmark, links

Normally, you can only link to a wiki page, or a specific section header. This is impractical when header names are long, or you expect that they might change. This plugin lets you create links to any part of your page.

This plugin is also a useful sample, if you're having trouble figuring out how to create a syntax plugin.

Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Examples/Usage

Here's how you create an anchor:

{{anchor:anchor_name:text}}

The anchor_name part is the name of the anchor to use in links. Note that the anchor_name has to begin with a letter between “a” and “z” and doesn't support upper case.

The text part is optional, and, for the most part, not very useful. It lets you wrap the anchor around a specific piece of text.

To link to an anchor from within DokuWiki:

[[namespace:page_name#anchor_name]]

To link to an anchor from outside DokuWiki:

http://server.com/doku/doku.php?id=page_name#anchor_name

Changelog

  • 2017-06-20 – Changed signature of methods handle and render to suppress warnings in PHP 7.1.
  • 2013-05-23 – Integrated changes made by Peter B to fix escaping vulnerability and paragraph formatting.

Discussion

Case sensitivity is not compatible with DW

While using anchor I found that you have to type the anchor_name in all lowercase letters to be compatible with the DW internal link mechanics, which converts the letters of a link to lowercase. To enable copy&paste of anchor names from other text-parts, it would be more convenient if the plugin did that itself.

Jumps to top of the page

I put an anchor at the bottom of a page.
If I use this internal link, DW jumps to the top of the page.
Isn't it possible to jump to the part of the page, where the anchor is defined?27.08.2013, Joe

/exe/fetch...

I created the plugin files and tried to create a link.
Instead of creating an anchor is makes a link to /lib/exe/fetch.php?media=anchor:anchor_name:text
What am I doing wrong?
EDIT: My bad, I was using the syntax incorrectly! :) Great work!
2013/11/03/ 01:56 Stephen V

Abbreviated use in page

Just to tell that it works fine and mostly to tell that even the short notation for the anchor works.
This makes the anchors within the page independent of the source page.
example: [[#anchorName|text]]
Great!!
ViForEver 20140207

Hello, in my private wiki it does not work. How i have to create an anchor and an anchor-goal? Please give me an example!

Old Discussion

plugin/anchor.1591280613.txt.gz · Last modified: 2020-06-04 16:23 by StarArmy

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