Add render hook for 'chem' code blocks #1286
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With PR #987 merged,
math
code blocks can now be used to display mathematical formulae, Based on this work, this PR adds the feature to usechem
code blocks to display chemical formulae. With this PR merged, you can now write something like:Please note that this PR relies on render hook templates, a feature that is available as of hugo 0.93. For users with older hugo versions., the old, now deprecated way of coding a formulae on its own line is still available.
Furthermore, this PR brings in some additions that streamline and ease the use of formulae for technical writers:
When `math' or 'chem' blocks are used on a page, the required scripts are now loaded automatically. There is no need to enable KaTeX and/or ´mhchem´ in the site configuration any more (only when using hugo 0.93 or newer).
Up to now, KaTeX and/or
mhchem
scripts were enabled in the sitewideconfig
file. Once enabled, scripts were loaded for all pages, even it there were no formulae present on the page. With this PR in place, activation of scripts is now possible on a per page basis, too, simply by adding attributes in the page front matter:Also, the documentation page in the user guide was adapted in order to reflect the changes introduced with this PR.