\ @ s d Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z d d l
Z
Gd
d d e Z Gd d
d
e Z i d d Z
d S)a
Admonition extension for Python-Markdown
========================================
Adds rST-style admonitions. Inspired by [rST][] feature with the same name.
The syntax is (followed by an indented block with the contents):
!!! [type] [optional explicit title]
Where `type` is used as a CSS class name of the div. If not present, `title`
defaults to the capitalized `type`, so "note" -> "Note".
rST suggests the following `types`, but you're free to use whatever you want:
attention, caution, danger, error, hint, important, note, tip, warning
A simple example:
!!! note
This is the first line inside the box.
Outputs:
Note
This is the first line inside the box
You can also specify the title and CSS class of the admonition:
!!! custom "Did you know?"
Another line here.
Outputs:
Did you know?
Another line here.
[rST]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
By [Tiago Serafim](http://www.tiagoserafim.com/).
)absolute_import)unicode_literals ) Extension )BlockProcessor)etreeNc @ s" e Z d Z d Z d d Z d S)AdmonitionExtensionz+ Admonition extension for Python-Markdown. c C s3 | j | | j j j d t | j d d S)z& Add Admonition to Markdown instance.
admonition_beginN)registerExtensionparserblockprocessorsaddAdmonitionProcessor)selfmd
md_globals r +build/lib/markdown/extensions/admonition.pyextendMarkdown6 s
z"AdmonitionExtension.extendMarkdownN)__name__
__module____qualname____doc__r r r r r r 3 s r c @ sO e Z d Z d Z d Z e j d Z d d Z d d Z d d Z
d
S)r r
zadmonition-titlez%(?:^|\n)!!!\ ?([\w\-]+)(?:\ "(.*?)")?c C s_ | j | } | j j | p^ | j d | j o^ | o^ | j d d j | j d k S)N class r ) lastChildREsearch
startswith
tab_lengthgetfind CLASSNAME)r parentblocksiblingr r r testE s zAdmonitionProcessor.testc C s" | j | } | j d } | j j | } | rS | | j d d } n | j | \ } } | r | j | \ } } t j | d } | j d d | j
| f | r t j | d }
| |
_ |
j d | j q n | } | j
j | | | r| j d | n d S)Nr r divr z%s %sp)r popr r! enddetabget_class_and_titler
SubElementsetr&