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 Syntax
14 ------
15
16 Tables are defined using the syntax established in [PHP Markdown Extra][php].
17
18 [php]: http://www.michelf.com/projects/php-markdown/extra/#table
19
20 Thus, the following text (taken from the above referenced PHP documentation):
21
22 ```md
23 First Header | Second Header
24 ------------- | -------------
25 Content Cell | Content Cell
26 Content Cell | Content Cell
27 ```
28
29 will be rendered as:
30
31 ```html
32 <table>
33 <thead>
34 <tr>
35 <th>First Header</th>
36 <th>Second Header</th>
37 </tr>
38 </thead>
39 <tbody>
40 <tr>
41 <td>Content Cell</td>
42 <td>Content Cell</td>
43 </tr>
44 <tr>
45 <td>Content Cell</td>
46 <td>Content Cell</td>
47 </tr>
48 </tbody>
49 </table>
50 ```
51
52 !!! seealso "See Also"
53 The [Attribute Lists](./attr_list.md) extension includes support for defining attributes on table cells.
54
55 Usage
56 -----
57
58 See [Extensions](index.md) for general extension usage. Use `tables` as the
59 name of the extension.
60
61 See the [Library Reference](../reference.md#extensions) for information about
62 configuring extensions.
63
64 The following options are provided to change the default behavior:
65
66 * **`use_align_attribute`**: Set to `True` to use `align` instead of an appropriate `style` attribute
67
68 Default: `'False'`
69
70
71 A trivial example:
72
73 ```python
74 markdown.markdown(some_text, extensions=['tables'])
75 ```
76
77 ### Examples
78
79 For an example, let us suppose that alignment should be controlled by the legacy `align`
80 attribute.
81
82 ```pycon
83 >>> from markdown.extensions.tables import TableExtension
84 >>> html = markdown.markdown(text,
85 ... extensions=[TableExtension(use_align_attribute=True)]
86 ... )
87 ```