8000 Add pre_convert hook by Convincible · Pull Request #9640 · jekyll/jekyll · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add pre_convert hook #9640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

Convincible
Copy link
Contributor

This is a 🙋 feature or enhancement.

Summary

Adds a new :pre_convert hook that is triggered immediately after a page, post or document is processed for Liquid tags, but before it is sent to the converter to generate HTML. This allows the final Markdown to be modified or read by a plugin before it is converted.

Context

Modifying or reading the file's Markdown content may be useful or essential for different kinds of plugins.

Although the Markdown content can be accessed from :pre_render, this is prior to Liquid tags being evaluated, and consequently the content may contain both Markdown and Liquid tags at this point. For instance:

This site was last updated on: {{ site.time | date_to_string }}

In this case, the plugin author wishes to work with the final string of "This site was last updated on: 25 July 2024".

There are a number of reasons why modifying or reading the final Markdown, as opposed to modifying or reading the final HTML (using :post_convert), may be preferable to the plugin author. One reason might be that it is closer to a plain text string, which may simplify parsing or pattern matching to achieve the plugin's goals. Another might be that the plugin author wishes to write a plugin that assumes the format of the input (e.g. Markdown) but not the output of the converter (which may vary across Jekyll installations).

The new hook is fully tested and documented, although I haven't referred to a Jekyll version number in which the new hook would be available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0