[pmwiki-users] custom markup for personalized <script> tag

Patrick R. Michaud pmichaud at pobox.com
Sat Apr 16 23:30:49 CDT 2005


On Sun, Apr 17, 2005 at 03:47:50AM +0200, Sergio Andreozzi wrote:
> Hello,
> 
> I'd like to be able to insert the following markup type in my wiki pages:
> [...]
> while the PARAMS part depends on the wiki page. This is to be able to 
> add my ebay advs in my website.
> 
> Markup("ebay", "inline", "/'ebay(.*?)ebay'/", "<script 
> src=\"http://syndicate.ebay.com/ebayshop/ebayshop.dll$1\"></script>");
> 
> The problem is that if I add in a wiki page the following text:
> 
> 'ebay?GetSellerList&uid=MYEBAYID&fontsize=2&numofitems=50&highlight=1&fontface=verdana&sortby=endtime&sortdir=asc&siteid=101&catid=0ebay'
> 
> this get translated like:
> 
> <script src="<a class='urllink' 
> href='http://syndicate.ebay.com/ebayshop/ebayshop.dll?GetSellerList&amp;uid=MYEBAYID&amp;fontsize=2&amp;numofitems=50&amp;highlight=1&amp;fontface=verdana&amp;sortby=endtime&amp;sortdir=asc&amp;siteid=101&amp;catid=0' 
> rel='nofollow'>http://syndicate.ebay.com/ebayshop/ebayshop.dll?GetSellerList&amp;uid=MYEBAYID&amp;fontsize=2&amp;numofitems=50&amp;highlight=1&amp;fontface=verdana&amp;sortby=endtime&amp;sortdir=asc&amp;siteid=101&amp;catid=0</a>"></script>
> 
> and of course it doesn't work.

Well, first note that the &amp;s are correct, if you have just & in there
it's not correct html and the browser may interpret it wrong.

So, we only need to get rid of the <a> tags.  The problem you're 
encountering is that the markup is being declared in the "inline" 
section, before links are translated, so the 
"src='http://syndicate.ebay.com...'" is being picked up by the bare 
link translator and getting converted to a link.

The easy solution is to use Keep() to preserve the <script> from
further PmWiki processing.  I'll also use ebay: as the markup
instead of 'ebay...ebay'.

Markup('ebay:', '<links',
  '/\\bebay:([^\\s$UrlExcludeChars][^\\s.,?!$UrlExcludeChars])/e',
  "'<:block>'.Keep('<script src=\"http://syndicate.ebay.com/ebayshop/ebayshop.dll?$1\"></script>')");

Then the markup

ebay:GetSellerList&uid=MYEBAYID&fontsize=2&numofitems=50&highlight=1&fontface=verdana&sortby=endtime&sortdir=asc&siteid=101&catid=0

correctly becomes

<script src="http://syndicate.ebay.com/ebayshop/ebayshop.dll?GetSellerList&amp;uid=MYEBAYID&amp;fontsize=2&amp;numofitems=50&amp;highlight=1&amp;fontface=verdana&amp;sortby=endtime&amp;sortdir=asc&amp;siteid=101&amp;catid=0"></script>

Pm



More information about the pmwiki-users mailing list