Debian Codegraph @

docs/src/markdown/extensions/blocks/plugins/definition.md

raw
1 ---
2 icon: lucide/book-a
3 ---
4 [:octicons-file-code-24:][_definition_block]{: .source-link }
5
6 # Definition
7
8 /// danger | Using `pymdownx.blocks.definition` with `def_list`
9 The new `pymdownx.blocks.definition` extension is meant to replace `def_list`, they are not meant to be used together.
10 Their output is identical making it easy to transition by simply swapping out the syntax, but using them both together
11 can cause issues as they both generate the same output and confuse each other.
12
13 If you are switching from `def_list` to `pymdownx.blocks.definition`, ensure you disable `def_list` to avoid issues.
14 ///
15
16 ## Overview
17
18 The definition blocks are an alternative to using Python Markdown's [built-in extension][def-list]. The output is very
19 similar, but they use the new generic block syntax.
20
21 By default, the meta-plugin is registered when `pymdownx.blocks` is registered, but if you were customizing which
22 meta-plugins get loaded, you can do so by doing the following:
23
24 ```py3
25 import markdown
26 md = markdown.Markdown(extensions=['pymdownx.blocks.definition'])
27 ```
28
29 ## Usage
30
31 Definitions can be specified using the generic block syntax and the name `define`. Simply create paragraphs for terms
32 and use a list to provide one or more definitions.
33
34 ```text title="Definition"
35 /// define
36 Apple
37
38 - Pomaceous fruit of plants of the genus Malus in
39 the family Rosaceae.
40
41 ///
42 ```
43
44 /// html | div.result
45 //// define
46 Apple
47
48 - Pomaceous fruit of plants of the genus Malus in
49 the family Rosaceae.
50
51 ////
52 ///
53
54 Multiple terms and definitions can be define in the same block. The terms will all be under the same definition list.
55
56 ```text title="Multiple Definitions"
57 /// define
58 Apple
59
60 - Pomaceous fruit of plants of the genus Malus in
61 the family Rosaceae.
62
63 Orange
64
65 - The fruit of an evergreen tree of the genus Citrus.
66
67 ///
68 ```
69
70 /// html | div.result
71 //// define
72 Apple
73
74 - Pomaceous fruit of plants of the genus Malus in
75 the family Rosaceae.
76
77 Orange
78
79 - The fruit of an evergreen tree of the genus Citrus.
80
81 ////
82 ///
83
84 Also, multiple terms can be associated with the same definition.
85
86
87 ```
88 /// define
89 Term 1
90
91 Term 2
92
93 - Definition a
94
95 Term 3
96
97 - Definition b
98 ///
99 ```
100
101 /// html | div.result
102 //// define
103 Term 1
104
105 Term 2
106
107 - Definition a
108
109 Term 3
110
111 - Definition b
112 ////
113 ///
114
115 As with all block plugins, you can always add new classes IDs or other attributes via the `attributes` option.
116
117 ```
118 /// define
119 attrs: {class: class-name: id: id-name}
120
121 Term 1
122
123 - Definition a
124 ///
125 ```
126
127 ## Global Options
128
129 Definitions provide no global options.
130
131 ## Per Block Options
132
133 Options | Type | Descriptions
134 ------------ | ---------- | ------------
135 `attrs` | dictionary | A dictionary that defines attributes for the outer, wrapper element.