How can I re-write image tag URLs with FilterPlugin's SUBST macro?

Refer to FilterPlugin's SUBST macro documentation. The pattern argument is a regular expression designed to match and capture text. The format parameter is used to replace the matched pattern, and in doing so can access any captured text inside parenthesis in the pattern.

In the following example, we want to re-write <img> tags so that <img src="filename.png"/> becomes <src="/pub/Support/Faq60/filename.png">

Error: no such plugin chili
%STARTSECTION{"test"}%
Original:
-----
%INCLUDE{"%TOPIC%Junk"}%
-----
Transformed:
-----
%SUBST{
  topic="%TOPIC%Junk"
  pattern="(<img[^>]*src=['\"])([^'\"]*)(['\"])"
  format="$1%ATTACHURLPATH%/$2$3"
  expand="off"
}%%ENDSECTION{"test"}%

Test

ALERT! This solution will include extraneous META lines until FilterPlugin's Tasks.Item11153 is fixed
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons LicenseGet Foswiki at sourceforge.net. Fast, secure and Free Open Source software downloads