File: hooks.py

package info (click to toggle)
mkdocs-test 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 424 kB
  • sloc: python: 938; sh: 34; makefile: 5
file content (22 lines) | stat: -rw-r--r-- 480 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
Hook script for altering the code
"""


MY_VARIABLES = {"x": 5, "y": 12, "message": 'hello world'}


def on_page_markdown(markdown:str, *args, **kwargs) -> str:
  """
  Process the markdown template, by interpolating the variables

  e.g. "{x} and {y}" -> "5 and 12"

  Note:
  -----
    .format(), contrary to f-strings, does not allow inline expressions:
    the expression "{x + y}" won't work.
  """
  raw_markdown = markdown.format(**MY_VARIABLES)
  return raw_markdown