The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Chronicle::Plugin::Tidy - Attempt to fix malformed HTML.

DESCRIPTION

This plugin is designed to try to prevent malformed HTML from being generated.

It does that by using the HTML::TreeBuilder module to parse the HTML that has been inserted into the SQLite database and then rewalks the tree to try to fix broken entries.

As an example the following bogus HTML will be fixed:

    <p>This is a line of text.</P>

Similarly tags that are not closed will be fixed up.

METHODS

Now follows documentation on the available methods.

on_insert

The on_insert method is automatically invoked when a new blog post must be inserted into the SQLite database, that might be because a post is new, or because it has been updated.

The method is designed to return an updated blog-post structure, after performing any massaging required. If the method returns undef then the post is not inserted.

Here we walk the HTML entry, which might have been written by hand or which might have been created via Chronicle::Plugin::Markdown, or some other plugin, and try to ensure it is well-formed.

_order

We want this plugin to be called after the other plugins which filter new entries - so that we can fix their broken HTML.