package org.j69.eewiki.wiki.tag;

import org.apache.oro.text.perl.Perl5Util;

import org.j69.eewiki.util.WebUtil;
import org.j69.eewiki.wiki.transformer.DataTag;

/**
 * Link Data Tag
 * @author <a href="mailto:agata@mobster.jp">Toshitaka Agata</a>
 * @version $Revision: 1.3 $ $Date: 2003/06/30 17:07:44 $
 */
public class LinkDataTag implements DataTag {
    /**
     * @see jp.mobster.webapp.wiki.transform.DataTag#get()
     */
    public String get(String pageData) {
        String tmp = pageData;
        Perl5Util perl = new Perl5Util();
		tmp = WebUtil.addLinkTagShadowURL(tmp, "_blank"); 
        tmp = WebUtil.addLinkTagURL(tmp, "_blank");
//        tmp = perl.substitute("s!<a.*>(https?\\://[\\!-~]+(jpg|gif|png))</a>!<img src=\"$1\">!g", tmp);
		tmp = perl.substitute("s!<a.*>(https?\\://[-_.\\!~*'a-zA-Z0-9;/?:@&=+$,%#]+(jpg|gif|png|txt))</a>!<img src=\"$1\">!g", tmp);
        tmp = WebUtil.addLinkTagFTP(tmp, "_blank");
        tmp = WebUtil.addLinkTagMail(tmp);
        return tmp;
    }
}
