1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
title: Legacy Attributes Extension
# Legacy Attributes
## Summary
The Legacy Attributes extension restores Python-Markdown's original attribute
setting syntax. Older versions of Python Markdown (prior to 3.0) included
built-in and undocumented support for defining attributes on elements. Most
users have never made use of the syntax and it has been deprecated in favor of
[Attribute Lists](attr_list.md). This extension restores the legacy behavior for
users who have existing documents which use the syntax.
## Syntax
Attributes are defined by including the following within the element you wish to
assign the attributes to:
```md
{@key=value}
```
For example, to define a class to a paragraph:
```md
A paragraph with the attribute defined {@class=foo}anywhere within.
```
Which results in the following output:
```html
<p class="foo">A paragraph with the attribute defined anywhere within.</p>
```
The same applies for inline elements:
```md
Some *emphasized{@id=bar}* text.
```
```html
<p>Some <em id="bar">emphasized</em> text.</p>
```
You can also define attributes in images:
```md

```
```html
<p><img alt="Alt text" id="baz" src="path/to/image.jpg" /></p>
```
## Usage
See [Extensions](index.md) for general extension usage. Use `legacy_attrs` as the
name of the extension.
This extension does not accept any special configuration options.
A trivial example:
```python
markdown.markdown(some_text, extensions=['legacy_attrs'])
```
|