Debian Codegraph @

docs/extensions/tables.md

raw
1 title: Tables Extension
2
3 Tables
4 ======
5
6 Summary
7 -------
8
9 The Tables extension adds the ability to create tables in Markdown documents.
10
11 This extension is included in the standard Markdown library.
12
13 !!! Note
14
15 This extension is in __maintenance mode__. We will continue to fix bugs
16 and keep it up-to-date with the core parser, but no new features or
17 changes in behavior will be made. If you need a feature that this
18 extension does not offer, then you have three options (1) find an
19 existing [third-party extension] which meets your needs, (2) [build your
20 own extension], or (3) fork this extension (pursuant to its licensing
21 requirements) and maintain it as a third-party extension.
22
23 [third-party extension]: index.md#third-party-extensions
24 [build your own extension]: api.md
25
26 Syntax
27 ------
28
29 Tables are defined using the syntax established in [PHP Markdown Extra][php].
30
31 [php]: http://www.michelf.com/projects/php-markdown/extra/#table
32
33 Thus, the following text (taken from the above referenced PHP documentation):
34
35 ```md
36 First Header | Second Header
37 ------------- | -------------
38 Content Cell | Content Cell
39 Content Cell | Content Cell
40 ```
41
42 will be rendered as:
43
44 ```html
45 <table>
46 <thead>
47 <tr>
48 <th>First Header</th>
49 <th>Second Header</th>
50 </tr>
51 </thead>
52 <tbody>
53 <tr>
54 <td>Content Cell</td>
55 <td>Content Cell</td>
56 </tr>
57 <tr>
58 <td>Content Cell</td>
59 <td>Content Cell</td>
60 </tr>
61 </tbody>
62 </table>
63 ```
64
65 !!! seealso "See Also"
66 The [Attribute Lists](./attr_list.md) extension includes support for defining attributes on table cells.
67
68 Usage
69 -----
70
71 See [Extensions](index.md) for general extension usage. Use `tables` as the
72 name of the extension.
73
74 See the [Library Reference](../reference.md#extensions) for information about
75 configuring extensions.
76
77 The following options are provided to change the default behavior:
78
79 * **`use_align_attribute`**: Set to `True` to use `align` instead of an appropriate `style` attribute
80
81 Default: `'False'`
82
83
84 A trivial example:
85
86 ```python
87 markdown.markdown(some_text, extensions=['tables'])
88 ```
89
90 ### Examples
91
92 For an example, let us suppose that alignment should be controlled by the legacy `align`
93 attribute.
94
95 ```pycon
96 >>> from markdown.extensions.tables import TableExtension
97 >>> html = markdown.markdown(text,
98 ... extensions=[TableExtension(use_align_attribute=True)]
99 ... )
100 ```