Skip to content

Add ability to run regex replacement on source content #3575

@minchinweb

Description

@minchinweb
  • I have searched the issues (including closed ones) and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.
  • I am willing to lend a hand to help implement this feature.

Feature Request

I'm hoping for a way to run a regex replacement on the source of articles are pages, but can't find the right signal to use. Maybe an additional signal needs to be added?

My current code is here --> https://github.com/minchinweb/minchin.pelican.plugins.clean_with_comments/blob/master/minchin/pelican/plugins/clean_with_comments/clean.py

It works (currently) off the content_written signal, but this has the double disadvantage of 1) being run after the site is basically entirely generated, so the summary is based on the removed text, and 2) requires reading and then re-writing files on disk, which is slow when dealing with thousands of files.

I tried the article_generator_write_article first (as it appears to be the logical time to do this in the flow of Pelican), but it only passes the metadata, and while you can access the article content, Pelican has no way for me to write back to it.

Is there a signal I'm missing that would provide me with the raw/unprocessed article source?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions