ParserHooks 1.1 released!

ParserHooks is a library that adds an object orientated and declarative parser hook interface on top of MediaWiki. (Read about the initial release)

Today I finished up and released version 1.1

The new features are support of tag extensions and a simplified way to register parser hook handlers.

If you want to register a tag extension rather then a parser function, simply call registerHookHandler rather then registerFunctionHandler on your HookRegistrant object. Just like registerFunctionHandler it takes both a ParserHookDefinition and a ParserHookHandler object. This essentially means that if you have a definition and a handler, you can register the parser hook both as tag extension and parser function with no extra work.

The simplification in the registration mechanism comes from the already mentioned registerFunctionHandler and registerHookHandler methods, which are new alternatives to registerFunction and registerHook, respectively. Rather then taking a FunctionRunner, or a HookRunner object, they simply take the only two required constructor arguments for these runner classes, and create the runners themselves. This removes the need to deal or even know about the runner objects. The registerFunction and registerHook are still there, to allow working with such runners in case you need to specify more advanced non-default behavior.

This release fixes a rather serious bug in parameter handling of parser functions. This bug had gone undetected by the unit tests, as it was a mismatch between my expectation of how the MediaWiki Parser interface would behave and reality. I discovered it when writing system tests for the SubPageList extension, which now uses ParserHooks. Lesson learned: no slacking off on writing system tests when interacting with a third party API not fully understood.

Updated documentation can be found in the readme file.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.