There are two main issues involved with NamedAnchorsInWiki
Once we have pages with named anchors in place, it might be handy to be able to automatically insert the list of named anchors as a small list.
Current suggestions for creating named anchors
Suggestions for referencing named anchors
Suggestion for bonus feature:
[CategoryMeatballWikiSuggestion]
I am thinking about placing named tags in a wiki page so that at this place in the page output, UseModWiki emits
<a name="named_anchors"></a>
so when I go to MeatBall:MeatballWikiSuggestions#named_anchors it goes to that location. I'm not sure what the WikiSyntax should be, but it would be handy when referring to specific entries in my diary or to entries in a (hypothetical) FAQ.
I've had several occasions when I wanted to specifically link to one entry on my diary, so it would be useful to me. <anchor>anchor_pattern</anchor> would be perfect. --ss
Patch
sub CommonMarkup { my ($text, $useImage, $doLines) = @_; local $_ = $text; if ($doLines < 2) { # 2 = do line-oriented only # The nowiki tag stores text with no markup (except quoting HTML) s/\<nowiki\>((.|\n)*?)\<\/nowiki\>/&StoreRaw($1)/ige; # The pre tag wraps the stored text with the HTML pre tag s/\<pre\>((.|\n)*?)\<\/pre\>/&StorePre($1)/ige; s/\<anchor\>(\w+)\<\/anchor>/&StoreHref(" name=\"$1\"")/ige; ## ADD THIS LINE
(Notice the bug: the <
and >
actually make it out as <
and >
instead of <
and >
. See the source of this page to understand what I mean.)
I've implemented [#anchor_name]
with this line of code:
s/\[\#(\w+)\]/&StoreHref(" name=\"$1\"")/ige;-- EricScheid
You could perhaps mark the === headline ===
syntax as named anchors ... automatically creating named anchors for page sections at the same time. Less work for everyone, plus encourages page structure over ThreadMess. Oooh ... you get something else for free if you do this: hierachical ordering of named anchors (eg. 1, 2, 2.1, 2.2, 2.2,1, 3, 4)
One problem is what to do with disallowed characters, such as spaces and punctuation, and also how to handle the situation of people editing the text and breaking links to that named anchor.
=== [anchorname] headline text goes here ===
-- EricScheid
See also: Named Anchor Links and Named Anchor Summary
Once we have named anchors in the page, we need some way to link to them, other than writing out the full URL by hand as in http://meatballwiki.org/wiki/MeatballWikiSuggestions#Anchor1.
Since named anchors won't necessarily be LinkPatterns?, it might be better to allow the link URL be hidden in the same way that [square-bracket-urls with textual link text] works. Thus, suggest format might be: [WikiName#anchorname display text]
-- EricScheid
For what it's worth, I agree completely. We don't want to get into the unreadable gook that is MeatballWikiSuggestions#Anchor1. Furthermore, this is amazingly similar to SubPages which are equally unreadable, in my humble opinion. (Sorry, Cliff ;) At least anchors are easier to navigate. -- SunirShah
Upon reflection, the simplest thing that could possibly work is to let WikiName#anchor be recognised as links ... then you could use them with [bracket notation] and InterWiki notation, or just plain jane unobfuscated.
Implementation ... would have to allow # in the wikilink pattern when rendering, and pass that through to the sub that creates the link. That sub would then check to see if there is a #anchor, and if so strips it off before checking to see if wikilink is a known WikiName, and then (if known) adds it back into the URL. Sigh ... looks like I'll be slurping spaghetti tonite. -- EricScheid
That's how they are currently implemented. Note how the undefined pages suppress anchors by a hereto unknown dependency in the code. SampleUndefinedPage#anchor SandBox#anchor
SampleUndefinedPage? SandBox#anchor -- SunirShah
Once we have named anchors in the page, it could well be handy to be able to automatically insert the list of those named anchors. Ideally, this would be via a wiki-tag so the list could be inserted after an introductory paragraph, left out entirely, etc. Bonus points if we could specify in the wiki-tag a different WikiName.
Thus:
<anchors> could produce:
and <anchors:WikiName> could produce:
where each of those lines is in fact a link to the corresponding anchor.
I'm not 100% liking the repetition of WikiName in that format though. Perhaps it could suffice to insert a table header
An example of where this could be useful is on MeatballWikiBugs, which could present an automatically updated table of contents of its sister page, MeatballWikiBugsResolved.
Note that by re-using the === headline === syntax we can introduce a hierachical structure to the anchor summary
-- EricScheid
Perhaps we just need yet another WikiSyntax for numbered headings. Perhaps, simply...
== # heading2 == === # heading3 === ==== # heading4 ====
which emits
... see UseMod:WikiPatches/NumberedHeadings
And then you can easily generate a TableOfContents. ... see UseMod:WikiPatches/TableOfContents