Debian Codegraph @

docs/src/markdown/faq.md

raw
1 ---
2 icon: lucide/circle-question-mark
3 ---
4 # Frequently Asked Questions
5
6 ## Function References in YAML
7
8 /// question
9 How do I specify function references in YAML if I am using a module like [MkDocs][mkdocs]?
10 ///
11
12 Pymdown Extensions has a number of extensions that expose customization via options that take function references. If
13 you are using a project like [MkDocs][mkdocs], which allows a user to configure Python Markdown extensions via YAML,
14 specifying function references may not be intuitive.
15
16 Keep in mind that the following examples specifically reference YAML configurations that are implemented via
17 [PyYAML][pyyaml] and are configured to allow Python objects.
18
19 When specifying a function reference in PyYAML, you must prepend the function with `#!yaml !!python/name:`. If you are
20 trying to configure a function with parameters -- like we require with `slugs.slugify` or `arithmatex`'s custom fences
21 for SuperFences -- then you must use `#!yaml !!python/object/apply:`. For instance, to specify Python Markdown's Toc
22 extension to use one of PyMdown Extensions' slugs in MkDocs, we will use the format so we can specify key word
23 arguments.
24
25 ```yaml
26 markdown_extensions:
27 - markdown.extensions.toc:
28 slugify: !!python/object/apply:pymdownx.slugs.slugify {kwds: {case: lower}}
29 permalink: "\ue157"
30 ```
31
32 If no parameters are needed, `#!yaml !!python/object/apply:` still require `{}` at the end.
33
34 ```yaml
35 markdown_extensions:
36 - markdown.extensions.toc:
37 slugify: !!python/object/apply:pymdownx.slugs.slugify {}
38 permalink: "\ue157"
39 ```
40
41 To specify a particular emoji generator in the Emoji extension, this requires just a simple function reference using
42 `#!yaml !!python/name:`. These take no parameters and do not require `{}` at the end.
43
44 ```yaml
45 markdown_extensions:
46 - pymdownx.emoji:
47 emoji_generator: !!python/name:pymdownx.emoji.to_png
48 ```
49
50 ## GitHub-ish Configurations
51
52 /// question
53 How do I get GitHub Flavored Markdown?
54 ///
55
56 A recommended GitHub configuration is provided below to emulate a setup that gives a GitHub feel.
57
58 For GitHub issue, commit, pull request, and mention shorthand syntax, you will also need to specify a `provider`, `user`
59 and `repo` in MagicLink's options below. This gives relative context for shorthand links (like `#1`) so that links can
60 properly be generated. In the example below, we will use `facelessuser` and `pymdown-extensions` as the user and
61 repository respectively. See [MagicLink](./extensions/magiclink.md) for more details.
62
63 /// tip
64 If you are attempting to configure these options in a YAML based configuration (like in [MkDocs][mkdocs]), please
65 see the related [FAQ question](#function-references-in-yaml) to see how to specify function references in YAML.
66 ///
67
68 ```py3
69 from pymdownx import emoji
70
71 extensions = [
72 'markdown.extensions.tables',
73 'pymdownx.magiclink',
74 'pymdownx.betterem',
75 'pymdownx.tilde',
76 'pymdownx.emoji',
77 'pymdownx.tasklist',
78 'pymdownx.superfences',
79 'pymdownx.saneheaders',
80 'pymdownx.quotes'
81 ]
82
83 extension_configs = {
84 "pymdownx.magiclink": {
85 "repo_url_shortener": True,
86 "repo_url_shorthand": True,
87 "provider": "github",
88 "user": "facelessuser",
89 "repo": "pymdown-extensions"
90 },
91 "pymdownx.tilde": {
92 "subscript": False
93 },
94 "pymdownx.emoji": {
95 "emoji_index": emoji.gemoji,
96 "emoji_generator": emoji.to_png,
97 "alt": "short",
98 "options": {
99 "attributes": {
100 "align": "absmiddle",
101 "height": "20px",
102 "width": "20px"
103 },
104 "image_path": "https://github.githubassets.com/images/icons/emoji/unicode/",
105 "non_standard_image_path": "https://github.githubassets.com/images/icons/emoji/"
106 }
107 },
108 "pymdownx.quotes": {
109 "callouts": True
110 }
111 }
112 ```
113
114 ## Mermaid Diagrams
115
116 The short answer is to use [SuperFences' custom fence feature](./extensions/superfences.md#custom-fences). We provide
117 a basic [example using SuperFences](./extensions/superfences.md#uml-diagram-example), but in order to get a really
118 solid Mermaid experience, we actually go a bit further in our documents. While we don't often have time to answer
119 everyone's questions regarding Mermaid, we have provided some fairly extensive notes on how we achieved Mermaid diagrams
120 in this documents. Check out the notes [here](./extras/mermaid.md).
121
122 ## Arithmatex Generic Mode Not Working in MkDocs
123
124 This question comes up every now and as there are a number of people that like to use Arithmatex in the MkDocs
125 environment. For whatever reason, people often gravitate towards the "generic" mode over the "default" mode. And
126 inevitably, we'll get an issue regarding why math rendering isn't working with Arithmatex in MkDocs.
127
128 If you are affected by this issue, the first question you should ask yourself is whether you are using the
129 [`mkdocs-minify-plugin`](https://github.com/byrnereese/mkdocs-minify-plugin). If you are using this plugin, you must
130 either discontinue using it (which is not usually the desired approach) or use Arithmatex's "default" mode and MathJax
131 configuration as outlined in its [documentation](./extensions/arithmatex.md#loading-mathjax).