Repository URL to install this package:
|
Version:
2.6.6 ▾
|
Markdown
/
postprocessors.pyc
|
|---|
ó
ÂöWc @@ 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 d Z
d
e j f d YZ d e f d
YZ
d e f d YZ d e f d YZ d S( u
POST-PROCESSORS
=============================================================================
Markdown also allows post-processors, which are similar to preprocessors in
that they need to implement a "run" method. However, they are run after core
processing.
i ( t absolute_import( t unicode_literals( t OrderedDicti ( t util( t odictNc K@ s: t j } t | | d <t | d <t | d <| S( u0 Build the default postprocessors for Markdown. u raw_htmlu amp_substituteu unescape( R R t RawHtmlPostprocessort AndSubstitutePostprocessort UnescapePostprocessor( t md_instancet kwargst postprocessors( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyt build_postprocessors s
t
Postprocessorc B@ s e Z d Z d Z RS( u
Postprocessors are run after the ElementTree it converted back into text.
Each Postprocessor implements a "run" method that takes a pointer to a
text string, modifies it as necessary and returns a text string.
Postprocessors must extend markdown.Postprocessor.
c C@ s d S( u¿
Subclasses of Postprocessor should implement a `run` method, which
takes the html document as a single text string and returns a
(possibly modified) string.
N( ( t selft text( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyt run' s ( t __name__t
__module__t __doc__R ( ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR s R c B@ s) e Z d Z d Z d Z d Z RS( u# Restore raw html to the document. c @ sd t xt | j j j D]÷ } | j j j | \ } } | j j r· | r· t | j j j d k r | j | } q· t | j j j d k r¨ d } q· | j j
} n | j | rý | sÙ | j j rý | d d | j j j | <n | | j j j | <q W r`t
j d j d D } | j f d | } n | S( u2 Iterate over html stash and restore "safe" html. u escapeu removeu u
u <p>%s</p>u |c s@ s | ] } t j | Vq d S( N( t ret escape( t .0t k( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pys <genexpr>H s c @ s | j d S( Ni ( t group( t m( t replacements( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyt <lambda>I s ( R t ranget markdownt htmlStasht html_countert
rawHtmlBlockst safeModet strt lowerR t html_replacement_textt isblocklevelt get_placeholderR t compilet joint sub( R
R t it htmlt safet pattern( ( R s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR 4 s" $"c C@ sF | j d d } | j d d } | j d d } | j d d S( u Basic html escaping u &u &u <u <u >u >u "u "( t replace( R
R* ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR M s c C@ sO t j d | } | rK | j d d d k r5 t St j | j d St S( Nu ^\<\/?([^ >]+)i i u !u ?u @u %( u !u ?u @u %( R t matchR t TrueR t isBlockLevelt False( R
R* R ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR$ T s ( R R R R R R$ ( ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR 1 s R c B@ s e Z d Z d Z RS( u Restore valid entities c C@ s | j t j d } | S( Nu &( R- R t AMP_SUBSTITUTE( R
R ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR a s ( R R R R ( ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR ^ s R c B@ s? e Z d Z e j d e j e j f Z d Z d Z
RS( u Restore escaped chars u %s(\d+)%sc C@ s t j t | j d S( Ni ( R t int2strt intR ( R
R ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyt unescapek s c C@ s | j j | j | S( N( t RER( R5 ( R
R ( ( s5 build/lib.linux-x86_64-2.7/markdown/postprocessors.pyR n s ( R R R R R&