| 1 |
title: Abbreviations Extension |
| 2 |
|
| 3 |
Abbreviations |
| 4 |
============= |
| 5 |
|
| 6 |
Summary |
| 7 |
------- |
| 8 |
|
| 9 |
The Abbreviations extension adds the ability to define abbreviations. |
| 10 |
Specifically, any defined abbreviation is wrapped in an `<abbr>` tag. |
| 11 |
|
| 12 |
The Abbreviations extension is included in the standard Markdown library. |
| 13 |
|
| 14 |
Syntax |
| 15 |
------ |
| 16 |
|
| 17 |
Abbreviations are defined using the syntax established in |
| 18 |
[PHP Markdown Extra][php]. |
| 19 |
|
| 20 |
[php]: http://www.michelf.com/projects/php-markdown/extra/#abbr |
| 21 |
|
| 22 |
Thus, the following text (taken from the above referenced PHP documentation): |
| 23 |
|
| 24 |
```md |
| 25 |
The HTML specification |
| 26 |
is maintained by the W3C. |
| 27 |
|
| 28 |
*[HTML]: Hyper Text Markup Language |
| 29 |
*[W3C]: World Wide Web Consortium |
| 30 |
``` |
| 31 |
|
| 32 |
will be rendered as: |
| 33 |
|
| 34 |
```html |
| 35 |
<p>The <abbr title="Hyper Text Markup Language">HTML</abbr> specification |
| 36 |
is maintained by the <abbr title="World Wide Web Consortium">W3C</abbr>.</p> |
| 37 |
``` |
| 38 |
|
| 39 |
The backslash (`\`) is not permitted in an abbreviation. Any abbreviation |
| 40 |
definitions which include one or more backslashes between the square brackets |
| 41 |
will not be recognized as an abbreviation definition. |
| 42 |
|
| 43 |
Usage |
| 44 |
----- |
| 45 |
|
| 46 |
See [Extensions](index.md) for general extension usage. Use `abbr` as the name |
| 47 |
of the extension. |
| 48 |
|
| 49 |
The following options are provided to configure the output: |
| 50 |
|
| 51 |
* **`glossary`**: |
| 52 |
A dictionary where the `key` is the abbreviation and the `value` is the definition. |
| 53 |
|
| 54 |
A trivial example: |
| 55 |
|
| 56 |
```python |
| 57 |
markdown.markdown(some_text, extensions=['abbr']) |
| 58 |
``` |
| 59 |
|
| 60 |
Disabling Abbreviations |
| 61 |
----------------------- |
| 62 |
|
| 63 |
When using the `glossary` option, there may be times when you need to turn off |
| 64 |
a specific abbreviation. To do this, set the abbreviation to `''` or `""`. |
| 65 |
|
| 66 |
```md |
| 67 |
The HTML abbreviation is disabled on this page. |
| 68 |
|
| 69 |
*[HTML]: '' |
| 70 |
``` |