Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/markdown/extensions/smart_strong.py

Issue 93743005: Support markdown template for html editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix path without dir Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 '''
2 Smart_Strong Extension for Python-Markdown
3 ==========================================
4
5 This extention adds smarter handling of double underscores within words.
6
7 Simple Usage:
8
9 >>> import markdown
10 >>> print markdown.markdown('Text with double__underscore__words.',
11 ... extensions=['smart_strong'])
12 <p>Text with double__underscore__words.</p>
13 >>> print markdown.markdown('__Strong__ still works.',
14 ... extensions=['smart_strong'])
15 <p><strong>Strong</strong> still works.</p>
16 >>> print markdown.markdown('__this__works__too__.',
17 ... extensions=['smart_strong'])
18 <p><strong>this__works__too</strong>.</p>
19
20 Copyright 2011
21 [Waylan Limberg](http://achinghead.com)
22
23 '''
24
25 from __future__ import absolute_import
26 from __future__ import unicode_literals
27 from . import Extension
28 from ..inlinepatterns import SimpleTagPattern
29
30 SMART_STRONG_RE = r'(?<!\w)(_{2})(?!_)(.+?)(?<!_)\2(?!\w)'
31 STRONG_RE = r'(\*{2})(.+?)\2'
32
33 class SmartEmphasisExtension(Extension):
34 """ Add smart_emphasis extension to Markdown class."""
35
36 def extendMarkdown(self, md, md_globals):
37 """ Modify inline patterns. """
38 md.inlinePatterns['strong'] = SimpleTagPattern(STRONG_RE, 'strong')
39 md.inlinePatterns.add('strong2', SimpleTagPattern(SMART_STRONG_RE, 'stro ng'), '>emphasis2')
40
41 def makeExtension(configs={}):
42 return SmartEmphasisExtension(configs=dict(configs))
OLDNEW
« no previous file with comments | « third_party/markdown/extensions/sane_lists.py ('k') | third_party/markdown/extensions/tables.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698