0

I have a Tiki page with some headlines formatted like this.

!!!schedule(%milliSeconds, %method, %arguments)

On another place (same wiki page) I have a simplified reference.

schedule()

Can Tiki automatically make a reference from schedule() to schedule(%milliSeconds, %method, %arguments) Meaning that schedule () will reference !!!schedule (%milliSeconds, %method, %arguments)

I hope this description makes sense :)

Max Kielland
  • 5,627
  • 9
  • 60
  • 95

2 Answers2

1

OK, here is an example:

{JQ()}
$('.wikitext p').html( function(){
    return $(this).html().replace(/\s([^\)\s)]+)\(\)/gi, ' <a href="#$1_a_b_c_">$1()</a>');
});
{JQ}

You can put this JQ plugin with jQuery code to top of a wiki page (or if you want it on every page then without the JQ plugin to the Customization > Custom JavaScript section of Look & Feel admin panel). Then if there is foo() or bar() or any function() mentioned in any paragraph of the page it will be converted to link pointing to an anchor on the same page, e.g.

<a href="#function_a_b_c_">function()</a>

where _a_b_c_ are the params (a,b,c) in the heading, for example

!!Function(a,b,c)

You need to change that _a_b_c_ to match your anchors as they are rendered (check the HTML source) or adjust the regular expression. That is out of the scope of this answer. You can see a demo here.

  • This sent me in the right direction. I have to elaborate a bit more to get the tags as I want them, but this is a good start... – Max Kielland Feb 28 '13 at 10:10
0

I am not sure I understand correctly but perhaps you could use the Hotwords feature, where you define schedule() as a "hotword" linking to YourWikiPageName#schedule(%milliSeconds, %method, %arguments). Then every mention of schedule() in Tiki will point to that anchor on that page.

  • 1
    I had a look at hotwords but that means I manually have to register hundreds of words with the risk of broken links if the description get moved. I wonder if was possible to have Tiki to automatically recognise words and create an anchor to a headline with the same name, like wikiwords automatically link to wiki pages. – Max Kielland Feb 18 '13 at 20:19
  • It is rather specific use case. That would need to be custom coded in Tiki's wiki syntax parsing to recognize these and keep them checked each time the page is edited if the targets are still present or (if you do not mind client side solution only) it could be coded using custom jQuery code to apply these links to matching anchors on page load. – luciash d' being Feb 18 '13 at 22:26
  • Alright, so there is no "easy" solution available out of the box then... Well JQuery is a rather "easy" solution in itself :P What would be the best way to implement the JQuery, use of – Max Kielland Feb 19 '13 at 12:47
  • I hope my second answer helps :) – luciash d' being Feb 27 '13 at 20:06