How to add additional element to htmlparser generator

aem, sling

Solution

Solution:

Add a child node under your rewriter node, which generatorType is generator-htmlparser:

<generator-htmlparser jcr:primaryType="nt:unstructured" includeTags="[SPAN,/SPAN]"/>

It will work only span tags with this configuration. The tag names must be capital letters!

Problem

I want to rewrite links in attributes of span tags with sling rewrite pipeline. The htmlparser generator only calls "a, link, script, img, form, body" elements. How can I add additional element like span to my transformer? An example configuration would be great! I read that a generator-htmlparser node should be created with the includeTags property, but it doesn't work! I tried to create this node under /apps/MY_APP/config/rewriter. There is also an other generatorType (html-generator), which works, but it calls on every html elements, which is not good for performance. I use AEM 5.6.1. Thanks in advance!

Original source