[Mediawiki-l] Parsing raw text

Thomas Dalton thomas.dalton at gmail.com
Fri Jan 4 14:22:43 UTC 2008

On 04/01/2008, Jack Eapen C <jackec at suntecgroup.com> wrote:
> By this time I hv figured out something
> Justing playing around with mediawiki and mysql fulltext search- I hv
> the following function:
> $wgHooks['ArticleSaveComplete'][] = 'getNormalTextfromWikiText';
> function getNormalTextfromWikiText(&$article,&$user,&$text)
> {
>    global $wgParser;
>    $result = $wgParser->parse($text, $wgParser->mTitle,
> $wgParser->mOptions);
>    $new_text= $result->getText();
>         $dbw =& wfGetDB( DB_MASTER );
>                         $dbw->insert( 'searchable_text',
>                                 array(
>                                 'page_id' => $article->getID(),
>                                 'searchable_text'    => $new_text
>                                 ) );
>          return true;
> }
> What I want is to insert normal text to a table and perform a mysql
> fulltext search on that table. i.e. if some user enters
> [http://en.wikipedia.org/ Link to Wikipedia] in article edit box, I want
> to insert "Link to Wikipedia" into my table. The "parse" in my above
> function is returning "<p><a href="http://en.wikipedia.org/"
> class="external text" target="_blank" title="http://en.wikipedia.org/"
> rel="nofollow">Link to Wikipedia</a>
> </p>". I don't want that. Simply needs "Link to Wikipedia". How can I
> get that?

Ah! I see. I was thinking about HTML tables and was completely
confused! Would a simple regexp that removes everything between < and
> do the trick? I've never really got the hang of regexps, so I won't
give you any code to try, but it should be a relatively easy one, I

More information about the MediaWiki-l mailing list