Commits

Jonathan Eunice committed 01f9a36

better comments and example

Comments (0)

Files changed (2)

+
+import markdown
+import mdx_smartypants
+
+md = markdown.Markdown(extensions=['smartypants'])
+
+md_text = """
+This is some Markdown. It's pretty nice, and simple. But--it could
+really use some typographic "prettification." That... That would
+be sweet. Definitely 7---8 on a '10-point scale'.
+
+Huzzah!
+"""
+
+print md.convert(md_text)
+
+
+# Expected output:
+
+# <p>This is some Markdown. It&rsquo;s pretty nice, and simple. But&mdash;it could
+# really use some typographic &ldquo;prettification.&rdquo; That&hellip; That would
+# be sweet. Definitely 7&ndash;8 on a &lsquo;10-point scale&rsquo;.</p>
+# <p>Huzzah!</p>

mdx_smartypants.py

+"""An extension to Python Markdown that uses smartypants to provide
+typographically nicer ("curly") quotes, proper ("em" and "en") dashes, etc.
+
+USAGE:
+
+import 
+"""
+
 from markdown.postprocessors import Postprocessor
 from markdown.extensions import Extension
 
 from smartypants import smartyPants
 
+
+# NAMED ENTITIES CODE
+
 # Most of the heavy-lifting is done by the smartypants module, but named HTML
 # entities are much easier to comprehend than numeric entities, so while we're
 # making the output typograpically prettier and more readable, let's take a
     return unescaped_text.encode('ascii', 'named_entities')
 
 
+# EXTENSION CODE
+
 # The following two classes and one module-level function link smartyPants and
 # named_entities into usable form via markdown's extension API.
 
     def run(self, text):
         return named_entities(smartyPants(text))
 
-
 class SmartypantsExt(Extension):
     
     def extendMarkdown(self, md, md_globals):
         md.postprocessors.add('smartypants', SmartypantsPost(md), '_end')
 
 
-def makeExtension(configs=None) :
+def makeExtension(configs=None):
     return SmartypantsExt(configs=configs)