Pergunta

1. Question

If I code like the following, then I have a link within the page to a specific "section"

[[#SectionTitle|displayed text]]

But what if I want to have a link within the page to a place, I mean any place?

Sometimes I might want to directly refer to a part of the page that isn't at the start of a section.

2. What I tried

I tried something like this

[[#Foo|displayed text]]
{{anchor|Foo}}

This seemed to ask me to make a page Template:Anchor

So I copied the Template:Anchor page of wikipedia.

But Template:Anchor again seemed to ask to make some new page, because Template:Anchor only says

{{#invoke:anchor|main}}

So my attempt didn't work.

Foi útil?

Solução

Use the following to create the anchor:

<div id="NameOfAnchorHere">optional text</div>

which can be referenced as:

[[#NameOfAnchorHere| test]]

More information about linking in MediaWiki can be found here

Outras dicas

And just to explain what's going on with {{#invoke:anchor|main}}: that's using Lua code in the Module namespace to generate the anchor.

Note that it eventually uses

<span id="NameOfAnchorHere">optional text</span>

which, I think, is nearly equivalent of <div style="display:inline;">, I think.

Put the closing tag at the end of the paragraph, not right after the anchor. That will then not cause a line break. Or use the span tag which can be immediately after the anchor.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top