mdx_smartypants / test / test.py

import markdown
# import mdx_smartypants

def test_smartypants():
    
    text = """
Markdown makes HTML from simple text files. But--it lacks typographic
"prettification." That... That'd be sweet. Definitely 7---8 on a '10-point
scale'. Now it has it.

Huzzah!
"""

    answer = """
<p>Markdown makes HTML from simple text files. But&mdash;it lacks typographic
&ldquo;prettification.&rdquo; That&hellip; That&rsquo;d be sweet. Definitely 7&ndash;8 on a &lsquo;10-point
scale&rsquo;. Now it has it.</p>
<p>Huzzah!</p>
"""
    result = markdown.markdown(text, extensions=['smartypants'])
   
    assert result.strip() == answer.strip()


def test_code():
    md = """
This is a "paragraph." It should have--nay, needs, typographic pretties.

    def something(a):
        "I am a doc string. I should not be curled"
        print a + ", huh?"  # i am code -- not em-dash safe

and this is not code. So...make me pretty!
"""

    result = markdown.markdown(md, extensions=['smartypants'])
    
    answer = """
<p>This is a &ldquo;paragraph.&rdquo; It should have&mdash;nay, needs, typographic pretties.</p>
<pre><code>def something(a):
    "I am a doc string. I should not be curled"
    print a + ", huh?"  # i am code -- not em-dash safe
</code></pre>
<p>and this is not code. So&hellip;make me pretty!</p>
"""
    
    assert result.strip() == answer.strip()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.