Page 1 of 1
text-highlightning for wikipedia-links
Posted: Tue Jun 27, 2006 4:32 pm
by parday_2003
hi
(ohje, auch noch englisch, na dann mal los

)
i used the search function but didn't find an accurate answer. i would like to highlight words, e.g. with [(
word)]. then they should be transformed automatically to wikipedia-links:
http://de.wikipedia.org/[b]word[/b].
is there already a plugin which is able to do, otherwise i think it's really easy to code (but not for me!!!

)
thanks in advance
edit: a "[?]" as in the glossary plugin would be great
Re: text-highlightning for wikipedia-links
Posted: Tue Jun 27, 2006 4:41 pm
by garvinhicking
Hi!
For that, the easist thing would be to use the "Markup: RegexpMarkup" plugin by Rob Astonishen, from the Spartacus repository.
You could then create your custom RegExp file for this. Save it in the "regexps" subdirectory of the plugin, as Wikipedia.php:
Code: Select all
<?php
// Wiki-Reference.
//
$regexpArray = array(
'SearchArray'=>array(
"/\[\((.*)\)\]/"
),
'ReplaceArray'=>array(
'<a href="http://de.wikipedia.org/\\1" target="_blank">\\1</a>'
)
);
You might need to remove the other files in the regexps/ directory, since else they would be also applied and would lead to confusion.
HTH,
Garvin
Posted: Tue Jun 27, 2006 5:28 pm
by parday_2003
wow
seems to work ... a bit:
when i write 2 or more words in one line the plugin is overstrained, eg:
[(hallo)] [(fernseher)]
the result is:
hallo)] [(fernseher ..... linked to
http://de.wikipedia.org/wiki/hallo)]%20[(fernseher
do you have an answer to this problem?
thanks!
Posted: Tue Jun 27, 2006 6:09 pm
by garvinhicking
Hi!
Yes, this is due to the greedy matching of the regexp. Change it to this:
Code: Select all
<?php
// Wiki-Reference.
//
$regexpArray = array(
'SearchArray'=>array(
"/\[\((.*)\)\]/U"
),
'ReplaceArray'=>array(
'<a href="http://de.wikipedia.org/\\1" target="_blank">\\1</a>'
)
);
(Note the added "/U" in the searcharray)
Regards,
Garvin
Posted: Fri Aug 17, 2007 3:01 pm
by gregman
Hi there,
I added this feature as "external wiki source" in the free wiki-links plugin. You can mark the tags with "{[" . I don't know the Markup Plugin but i guess the advantage in the wiki-links plugin ist that you can configure the url and set a specific style in your templates css file. The only thing is that i can't modify the belgium language file

But if anybody is interested in it...
Greg
Re: text-highlightning for wikipedia-links
Posted: Fri Aug 17, 2007 3:45 pm
by stm999999999
garvinhicking wrote:
You could then create your custom RegExp file for this. Save it in the "regexps" subdirectory of the plugin, as Wikipedia.php:
there is already a wikipedia.php in the regexps-folder!
But, to be more compliant to the wiki-syntax these should work, too:
[(Wikipedia-word|another link text)]
for this:
Code: Select all
<?php
// Wiki-Reference.
//
$regexpArray = array(
'SearchArray'=>array(
"/\[\((.*)\)\]/U",
"/\[\((.*|.*)\)\]/U"
),
'ReplaceArray'=>array(
'<a href="http://de.wikipedia.org/wiki/\\1" target="_blank">\\1</a>',
'<a href="http://de.wikipedia.org/wiki/\\1" target="_blank">\\2</a>'
)
);
perhaps it should be taken in the CVS?
Re: text-highlightning for wikipedia-links
Posted: Fri Aug 17, 2007 3:51 pm
by stm999999999
parday_2003 wrote:
edit: a "[?]" as in the glossary plugin would be great
this should be for what? As a sign "this is a wikipedia-link"?
If yes: Have a look at
http://blog.stephan.manske-net.de/ there every wp-link has an wp-icon. Is this a solution for you?