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">
%STARTSECTION{"test"}%
Original:
-----
%INCLUDE{"%TOPIC%Junk"}%
-----
Transformed:
-----
%SUBST{
topic="%TOPIC%Junk"
pattern="(<img[^>]*src=['\"])([^'\"]*)(['\"])"
format="$1%ATTACHURLPATH%/$2$3"
expand="off"
}%%ENDSECTION{"test"}%
Test
This solution will include extraneous META
lines until FilterPlugin's Tasks.Item11153 is fixed