Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

Plugin ElementHook



It is possible to modify the wiki source tree content before the generation through a Plugin.

PluginFactory interface


To modify the wiki source tree content before the generation, you must implement the following methods in the PluginFactory interface:

ElementHook interface

The PluginFactory returns an implementation of the ElementHook interface, which will be used on then elements in the wiki source tree. This interface has the following methods:
   /**
   * Return the set of elements declarations which will be handled by this ElementHook.
   */
   public Set<String> supportedElements();

   /**
   * Start the processing of an article.
   */
   public default void startArticle(XMLArticle article) {
   }

   /**
   * Handle an element.
   */
   public void handleElement(ParagraphElement element);
  • The supportedElements() method returns the Set of elements in the wiki source tree which will potentially be handled by the hook[1]
    For example if you return "title", only syntax elements will be handled
    . See Elements declarations for more information
  • The handleElement(ParagraphElement) method will be called for all elements in the wiki source tree whose declaration ID is supported. For example, if supportedElements() returns a set with only "title", the method will be fired only for syntax elements

HookContext class

The HookContext is passed to the PluginFactory instance to create an ElementHook object. This class provides several methods to modify the content of the tree, including:
  • Inserting a list of elements in the source tree before or after the current element
  • Removing the current element

Notes

  1. ^ For example if you return "title", only syntax elements will be handled

See also


Categories: plugins

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.