\ @sdZddlmZddlmZddlmZddlmZddlm Z dd l m Z m Z dd l Z e jd ZGd d d eZGdddeZGddde Zd ddZd S)a Abbreviation Extension for Python-Markdown ========================================== This extension adds abbreviation handling to Python-Markdown. Simple Usage: >>> import markdown >>> text = """ ... Some text with an ABBR and a REF. Ignore REFERENCE and ref. ... ... *[ABBR]: Abbreviation ... *[REF]: Abbreviation Reference ... """ >>> print markdown.markdown(text, ['abbr'])

Some text with an ABBR and a REF. Ignore REFERENCE and ref.

Copyright 2007-2008 * [Waylan Limberg](http://achinghead.com/) * [Seemant Kulleen](http://www.kulleen.org/) )absolute_import)unicode_literals) Extension) Preprocessor)Pattern)etree AtomicStringNz,[*]\[(?P[^\]]*)\][ ]?:\s*(?P.*)c���������������@���s"���e��Z�d��Z�d�Z�d�d���Z�d�S) AbbrExtensionz- Abbreviation Extension for Python-Markdown. c�������������C���s ���|�j��j�d�t�|��d��d�S)z7 Insert AbbrPreprocessor before ReferencePreprocessor. abbrz <referenceN) preprocessorsaddAbbrPreprocessor)selfmd md_globals�r���%build/lib/markdown/extensions/abbr.pyextendMarkdown(���s����zAbbrExtension.extendMarkdownN)__name__ __module__ __qualname____doc__r���r���r���r���r���r ���%���s��� r ���c���������������@���s.���e��Z�d��Z�d�Z�d�d���Z�d�d���Z�d�S)r���z= Abbreviation Preprocessor - parse text for abbr references. c�������������C���s���g��}�x�|�D]{�}�t��j�|��}�|�r{�|�j�d��j���}�|�j�d��j���}�t�|��j�|��|��|��j�j�d�|�<q �|�j�|��q �W|�S)z Find and remove all Abbreviation references from the text. Each reference is set as a new AbbrPattern in the markdown instance. r ���titlezabbr-%s) ABBR_REF_REmatchgroupstrip AbbrPattern_generate_patternmarkdowninlinePatternsappend)r���linesnew_textlinemr ���r���r���r���r���run0���s���� )zAbbrPreprocessor.runc�������������C���sL���t��|��}�x,�t�t�|���D]�}�d�|�|�|�|�<q�Wd�d�j�|��S)a �� Given a string, returns an regex pattern to match that string. 'HTML' -> r'(?P<abbr>[H][T][M][L])' Note: we force each char as a literal match (in brackets) as we don't know what they will be beforehand. z[%s]z(?P<abbr>\b%s\b)�)listrangelenjoin)r���textcharsir���r���r���r ���B���s���� z"AbbrPreprocessor._generate_patternN)r���r���r���r���r(���r ���r���r���r���r���r���-���s���  r���c�������������������s4���e��Z�d��Z�d�Z���f�d�d���Z�d�d���Z���S)r���z Abbreviation inline pattern. c����������������s#���t��t�|���j�|��|�|��_�d��S)N)superr���__init__r���)r���patternr���) __class__r���r���r2���U���s����zAbbrPattern.__init__c�������������C���s>���t��j�d��}�t�|�j�d���|�_�|�j�d�|��j��|�S)Nr ���r���)r ���Elementr ���r���r.���setr���)r���r'���r ���r���r���r��� handleMatchY���s����zAbbrPattern.handleMatch)r���r���r���r���r2���r7���r���r���)r4���r���r���R���s��� r���c�������������C���s ���t��d�|���S)Nconfigs)r ���)r8���r���r���r��� makeExtension_���s����r9���)r��� __future__r���r���r)���r���r ���r���inlinepatternsr���utilr ���r ���recompiler���r ���r���r���r9���r���r���r���r���<module>���s��� %