0
votes

I use {% include text.md %} in my posts to include some often typed paragraphs.

I have a Generator plugin that makes some text replacement in post contents.

However, the text inside the included files (e.g. text.md) is not processed by this plugin.

How can I run the plugin after includes are performed but before html is rendered? Or how could I do things differently to make it work?

1
What is the generator exactly doing (input, output) ? Did you need to create new pages ?David Jacquel
@DavidJacquel It simply replaces some keywords by others. for instance replace machine learning with <em>machine-learning</em>Julien__
Why don't you use the {{ content | replace: "foo", "bar" }} filter ?David Jacquel
@DavidJacquel I have several hundreds of keywords that are aggregated from post content and replacement contain liquid tagsJulien__
Curious to know more. How did you aggregate ? What are you replacing ?David Jacquel

1 Answers

2
votes

Jekyll processes a site in distinct "phases".

  reset >> read >> generate >> render >> cleanup >> write

A Generator subclass is generally used to "generate" objects (Pages or Documents) that are then rendered based on the prioritydefined for the generator.

An include tag (or any Liquid constructs) is "rendered" in the subsequent phase.

Unfortunately, you cannot alter the "raw content" of a file in the middle of the rendering phase. Jekyll provides you with just a :pre_render hook to manipulate unrendered content of a file.