Mediawiki:具有多个名称的同一节(节别名/同义词) [英] Mediawiki: Same section with multiple names (section aliases/synonyms)

查看:158
本文介绍了Mediawiki:具有多个名称的同一节(节别名/同义词)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在MediaWiki中为同一部分提供多个现成的名称(非常推荐),或者我是否需要编写自己的hook/extension/plugin(如果是,则提供有关操作方法的提示)非常感谢)?

对于我来说,我在单个编译页面上有示例代码,我想通过每篇文章的名称链接到多篇单独的文章.例如,我想要以下工作.

页面:中断代码示例

===(EIMSK|EICRA)===
void interrupt01_init(void)                                                     
 {                                                                               
   EICRA = 0X0F; // in binary, 1111. That is, the rising edge of INT1 and INT0 generate an interrupt request. 
   EIMSK = 0X03; // in binary, 0011. Enables INT0 and INT1 interrupts.                           
 }

以及以下两个链接都将链接到同一部分,但每个页面的名称均应适当

页面:EICRA:

[[Interrupts Code Examples#{{PAGENAME}}]]

页面:EIMSK:

[[Interrupts Code Examples#{{PAGENAME}}]]

有关完整上下文,请参见示例页面 http://narwhaledu.com/AVRwiki/index.php?title = PCMSK0 .

我可能会使用类似 http://narwhaledu.com/AVRwiki/index.php?title= Interrupts_Code_Examples ,我有一个关于"部分.

如果不清楚,最好是用户访问的时间

页面:中断代码示例#PAGENAME

他们看到的是正确填充的部分标题,而不是"EIMSK或EICRA示例代码"(因为代码示例可能有很多别名)

==={{{PAGENAME}}}===
void interrupt01_init(void)                                                     
 {                                                                               
   EICRA = 0X0F; // in binary, 1111. That is, the rising edge of INT1 and INT0 generate an interrupt request. 
   EIMSK = 0X03; // in binary, 0011. Enables INT0 and INT1 interrupts.                           
 }

我可以使用包容性,但不能使用链接.

页面:模板:中断代码示例

=={{#ifexist: {{{pagename}}} | [[{{{pagename}}}]] | External Interrupts Example Code One}}==
{{Template:ExampleCode~PCMSK0, PCMSK1, PCMSK2, PCICR, PCINT0_vect, PCINT1_vect}}

我理想的语法是

[[ Template:Interrupts Code Examples|pagename={{PAGENAME}} ]]

,但是显然这会生成到不存在的页面pagename=Name_of_Register的链接,而不是链接到Interrupts Code Examples并传递参数{{PAGENAME}},这样我就可以在Interrupts Code Examples中使用{{{pagename}}}引用它,从而生成我的部分标头.

这将使编译页面保持整洁(只有两个代码示例,而不是将每个别名的每个示例复制5次,这是我当前的解决方案),但是如果我进行跨接,则只能将参数传递给模板,而如果我链接到模板,则不能传递参数模板,我相信.这是真的吗?

最后,我可能只使用示例代码一"包来增强Wiki标记的可读性,因为这开始让我大失所望...

解决方案

任何HTML锚都将用作部分链接.因此,如果您有<span id="foo">,则可以使用[[Bla#foo]]跳转到跨度.每个ID您需要一个HTML元素,但是我认为仍然可以使用.

Is it possible to give the same section multiple names in mediawiki out-of-the-box (vastly preferred), or do I need to write my own hook/extension/plugin (and if so, tips on how to do so much appreciated)?

In my case, I have example code on single compilation page that I want to link to for multiple individual articles by the name of each article. For instance, I would like something like the following the work.

Page: Interrupts Code Examples

===(EIMSK|EICRA)===
void interrupt01_init(void)                                                     
 {                                                                               
   EICRA = 0X0F; // in binary, 1111. That is, the rising edge of INT1 and INT0 generate an interrupt request. 
   EIMSK = 0X03; // in binary, 0011. Enables INT0 and INT1 interrupts.                           
 }

and both of the following would link to the same section, but with the appropriate name for each page:

Page: EICRA:

[[Interrupts Code Examples#{{PAGENAME}}]]

Page: EIMSK:

[[Interrupts Code Examples#{{PAGENAME}}]]

For full context, see example page http://narwhaledu.com/AVRwiki/index.php?title=PCMSK0.

It's possible I could use something like mediawiki: is there a way to automatically create redirect pages that redirect to the current page?, but is it possible to write it for sections instead of pages? Also, although acceptable, I would prefer not to have the allowed aliases be ALL the sections on a page; for instance, on http://narwhaledu.com/AVRwiki/index.php?title=Interrupts_Code_Examples, I have an "about" section.

Edit: If it wasn't clear, ideally the when the user visits

Page: Interrupts Code Examples#PAGENAME

they see a properly populated section title, instead of "EIMSK or EICRA Example Code" (since there can be a LOT of aliases to a code example)

==={{{PAGENAME}}}===
void interrupt01_init(void)                                                     
 {                                                                               
   EICRA = 0X0F; // in binary, 1111. That is, the rising edge of INT1 and INT0 generate an interrupt request. 
   EIMSK = 0X03; // in binary, 0011. Enables INT0 and INT1 interrupts.                           
 }

I can get transclusion to work but not links.

Page: Template:Interrupts Code Examples

=={{#ifexist: {{{pagename}}} | [[{{{pagename}}}]] | External Interrupts Example Code One}}==
{{Template:ExampleCode~PCMSK0, PCMSK1, PCMSK2, PCICR, PCINT0_vect, PCINT1_vect}}

My ideal syntax would be

[[ Template:Interrupts Code Examples|pagename={{PAGENAME}} ]]

but obviously this produces instead a link to the nonexistant page pagename=Name_of_Register instead of linking to Interrupts Code Examples and passing the parameter {{PAGENAME}} such that I can reference it in Interrupts Code Examples with {{{pagename}}} and thereby generate my section header..

This would keep the compilation page clean (only have two code examples instead of copying each one 5x for each alias, my current solution), but I can only pass parameters to the template if I transclude, not if I link to the template, I believe. Is this true?

I may just use the "Example Code One" catchall for wiki markup readability in the end since this is starting to break my brain...

解决方案

Any HTML anchor will work as a section link. So, if you have <span id="foo">, you can use [[Bla#foo]] to jump to the span. You'll need one HTML element per ID, but that's still workable I think.

这篇关于Mediawiki:具有多个名称的同一节(节别名/同义词)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆