Plugin jsoup filter interface
Introduction
Jsoup filters which enable the manipulation of HTML documents using their DOM structure maybe be included as part of a plugin by implementing the plugin’s jsoup filter interface.
Document filters can also be implemented for plugins using the document filter interface. |
Interface methods
Each jsoup filter included as part of a plugin must extend the IJSoupFilter
interface.
The process of implementing a filter for use with a plugin is the same as writing a general document filter, however it must be written in pure java rather than in Groovy.
The main methods you will want to implement are:
default void setup(SetupContext setup) {
and
void processDocument(FilterContext context);
Usage
To use a jsoup filter that is included as part of a plugin, you must first enable the plugin to make it available on the class path, then add a filter to the jsoup filter chain of the collection to specify when it runs.
For example, to use the ExampleJsoupFilter
from the exampleplugin
:
filter.jsoup.classes=ContentGeneratorUrlDetection,FleschKincaidGradeLevel,com.funnelback.plugin.exampleplugin.ExampleJsoupFilter
each plugin that implements this interface should mention the class name to use in the plugin documentation. |
Examples
The following is an example plugin which provides jsoup filter. It counts the number of elements which contain a specified class name.