|
1 | 1 | from __future__ import unicode_literals |
2 | 2 |
|
3 | | -from textile import Textile |
| 3 | +import textile |
4 | 4 | from textile.objects import Block |
5 | 5 |
|
6 | 6 | try: |
|
9 | 9 | from ordereddict import OrderedDict |
10 | 10 |
|
11 | 11 | def test_block(): |
12 | | - t = Textile() |
| 12 | + t = textile.Textile() |
13 | 13 | result = t.block('h1. foobar baby') |
14 | 14 | expect = '\t<h1>foobar baby</h1>' |
15 | 15 | assert result == expect |
@@ -41,16 +41,68 @@ def test_block(): |
41 | 41 | assert result == expect |
42 | 42 |
|
43 | 43 | def test_block_tags_false(): |
44 | | - t = Textile(block_tags=False) |
| 44 | + t = textile.Textile(block_tags=False) |
45 | 45 | assert t.block_tags is False |
46 | 46 |
|
47 | 47 | result = t.parse('test') |
48 | 48 | expect = 'test' |
49 | 49 | assert result == expect |
50 | 50 |
|
51 | 51 | def test_blockcode_extended(): |
52 | | - input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext' |
53 | | - expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>' |
54 | | - t = Textile() |
| 52 | + input = 'bc.. text\nmoretext\n\nevenmoretext\n\nmoremoretext\n\np. test' |
| 53 | + expect = '<pre><code>text\nmoretext\n\nevenmoretext\n\nmoremoretext</code></pre>\n\n\t<p>test</p>' |
| 54 | + t = textile.Textile() |
55 | 55 | result = t.parse(input) |
56 | 56 | assert result == expect |
| 57 | + |
| 58 | +def test_blockcode_in_README(): |
| 59 | + with open('README.textile') as f: |
| 60 | + readme = ''.join(f.readlines()) |
| 61 | + result = textile.textile(readme) |
| 62 | + expect = """ <p><a href="https://travis-ci.org/textile/python-textile"><img alt="" src="https://travis-ci.org/textile/python-textile.svg" /></a> <a href="https://coveralls.io/github/textile/python-textile?branch=master"><img alt="" src="https://coveralls.io/repos/github/textile/python-textile/badge.svg" /></a> <a href="https://codecov.io/github/textile/python-textile"><img alt="" src="https://codecov.io/github/textile/python-textile/coverage.svg" /></a></p> |
| 63 | +
|
| 64 | + <h1>python-textile</h1> |
| 65 | +
|
| 66 | + <p>python-textile is a Python port of <a href="http://txstyle.org/">Textile</a>, Dean Allen’s humane web text generator.</p> |
| 67 | +
|
| 68 | + <h2>Installation</h2> |
| 69 | +
|
| 70 | + <p><code>pip install textile</code></p> |
| 71 | +
|
| 72 | + <p>Optional dependencies include: |
| 73 | + <ul> |
| 74 | + <li><a href="http://python-pillow.github.io/"><span class="caps">PIL</span>/Pillow</a> (for checking images size)</li> |
| 75 | + <li><a href="https://pypi.python.org/pypi/regex">regex</a> (for faster unicode-aware string matching).</li> |
| 76 | + </ul></p> |
| 77 | +
|
| 78 | + <h2>Usage</h2> |
| 79 | +
|
| 80 | +<pre><code>import textile |
| 81 | +>>> s = """ |
| 82 | +... _This_ is a *test.* |
| 83 | +... |
| 84 | +... * One |
| 85 | +... * Two |
| 86 | +... * Three |
| 87 | +... |
| 88 | +... Link to "Slashdot":http://slashdot.org/ |
| 89 | +... """ |
| 90 | +>>> html = textile.textile(s) |
| 91 | +>>> print html |
| 92 | + <p><em>This</em> is a <strong>test.</strong></p> |
| 93 | +
|
| 94 | + <ul> |
| 95 | + <li>One</li> |
| 96 | + <li>Two</li> |
| 97 | + <li>Three</li> |
| 98 | + </ul> |
| 99 | +
|
| 100 | + <p>Link to <a href="http://slashdot.org/">Slashdot</a></p> |
| 101 | +>>></code></pre> |
| 102 | +
|
| 103 | + <h3>Notes:</h3> |
| 104 | +
|
| 105 | + <ul> |
| 106 | + <li>Active development supports Python 2.6 or later (including Python 3.2+).</li> |
| 107 | + </ul>""" |
| 108 | + assert result == expect |
0 commit comments