forked from sebix/python-textile
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
2,312 additions
and
1,857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[run] | ||
branch = True | ||
|
||
[report] | ||
show_missing = True | ||
omit = | ||
textile/tests/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,25 @@ | ||
language: python | ||
env: | ||
- REQUIREMENTS=true | ||
- REQUIREMENTS=false | ||
python: | ||
- "2.6" | ||
- "2.7" | ||
- "3.2" | ||
- "3.3" | ||
- "3.4" | ||
- "3.5" | ||
- "pypy" | ||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
- python setup.py -q install | ||
- if [[ ! $TRAVIS_PYTHON_VERSION == pypy ]] ; then pip install regex; fi | ||
- if [[ $REQUIREMENTS == true ]] ; then pip install -r requirements.txt ; fi | ||
- if [[ $TRAVIS_PYTHON_VERSION == '3.2' ]] ; then pip install coverage==3.7.1; fi | ||
- pip install coveralls pytest pytest-cov coverage codecov | ||
- pip install -e . | ||
- if [[ ! $TRAVIS_PYTHON_VERSION == 'pypy' ]] ; then pip install regex; fi | ||
# command to run tests | ||
script: nosetests | ||
script: py.test | ||
sudo: false | ||
after_success: | ||
- coveralls | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,38 @@ | ||
h1. Textile Changelog | ||
|
||
h1. Version 2.2.1 | ||
h2. Version 2.3.1 | ||
* Regression bugfix: empty string input returns empty string again. | ||
|
||
h2. Version 2.3.0 | ||
|
||
* Bugfixes: | ||
** Support data URIs in img tags | ||
** Fix autolink urls with image references ("#17":https://github.com/textile/python-textile/issues/17) | ||
** Fix textile links containing parentheses ("#20":https://github.com/textile/python-textile/issues/20) | ||
** Fix double-encoding of code blocks ("#21":https://github.com/textile/python-textile/issues/21) | ||
** Fix handling of scheme in self-linked URLs ("#16":https://github.com/textile/python-textile/issues/16) | ||
** Fix Markup not parsed if followed by certain characters ("#22":Markup not parsed if followed by certain characters) | ||
* Convert testing over to "py.test":http://pytest.org/, improving unicode testing | ||
* Update functionality for tables, notelists, and footnotes. This involved a major reworking of parts of the code, but it should now match php-textile and txstyle.org precisely. Please file an issue for any bugs you come across. | ||
|
||
h2. Version 2.2.2 | ||
|
||
* bugfix: "regex":https://pypi.python.org/pypi/regex is now an optional dependency | ||
|
||
h2. Version 2.2.1 | ||
|
||
* drop textilefactory support for html. | ||
* Various development-related bugfixes. | ||
* Added this changelog. | ||
|
||
h1. Version 2.2.0 | ||
h2. Version 2.2.0 | ||
|
||
* Started refactoring the code to be less repetitive. @textile.Textile().parse()@ is a little more friendly than @textile.Textile().textile()@ There may be more work to be done on this front to make the flow a little smoother. | ||
* We now support versions 2.6 - 3.4 (including 3.2) using the same codebase. Many thanks to Radek Czajka for this. | ||
* Drop support for html4. We now only output xhtml or html5. | ||
* Various development-related bugfixes. | ||
|
||
h1. Version 2.1.8 | ||
h2. Version 2.1.8 | ||
|
||
* Add support for html5 output. | ||
* Lots of new functionality added bringing us in line with the official Textile 2.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
testpaths = tests | ||
addopts = --cov=textile --cov-report=html --cov-append --cov-report=term-missing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
nose==1.3.4 | ||
coverage==3.7.1 | ||
html5lib==0.999 | ||
Pillow==2.6.0 | ||
Pillow==3.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
[nosetests] | ||
detailed-errors=1 | ||
with-coverage=1 | ||
cover-package=textile | ||
cover-erase=1 | ||
with-doctest=1 | ||
with-id = 1 | ||
[aliases] | ||
test=pytest | ||
[bdist_wheel] | ||
universal=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from textile.utils import parse_attributes | ||
import re | ||
|
||
def test_parse_attributes(): | ||
assert parse_attributes('\\1', element='td') == {'colspan': '1'} | ||
assert parse_attributes('/1', element='td') == {'rowspan': '1'} | ||
assert parse_attributes('^', element='td') == {'style': 'vertical-align:top;'} | ||
assert parse_attributes('{color: blue}') == {'style': 'color: blue;'} | ||
assert parse_attributes('[en]') == {'lang': 'en'} | ||
assert parse_attributes('(cssclass)') == {'class': 'cssclass'} | ||
assert parse_attributes('(') == {'style': 'padding-left:1em;'} | ||
assert parse_attributes(')') == {'style': 'padding-right:1em;'} | ||
assert parse_attributes('<') == {'style': 'text-align:left;'} | ||
assert parse_attributes('(c#i)') == {'class': 'c', 'id': 'i'} | ||
assert parse_attributes('\\2 100', element='col') == {'span': '2', 'width': '100'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from __future__ import unicode_literals | ||
|
||
from textile import Textile | ||
from textile.objects import Block | ||
|
||
try: | ||
from collections import OrderedDict | ||
except ImportError: | ||
from ordereddict import OrderedDict | ||
|
||
def test_block(): | ||
t = Textile() | ||
result = t.block('h1. foobar baby') | ||
expect = '\t<h1>foobar baby</h1>' | ||
assert result == expect | ||
|
||
b = Block(t, "bq", "", None, "", "Hello BlockQuote") | ||
expect = ('blockquote', OrderedDict(), 'p', OrderedDict(), | ||
'Hello BlockQuote') | ||
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content) | ||
assert result == expect | ||
|
||
b = Block(t, "bq", "", None, "http://google.com", "Hello BlockQuote") | ||
citation = '{0}1:url'.format(t.uid) | ||
expect = ('blockquote', OrderedDict([('cite', | ||
'{0.uid}{0.refIndex}:url'.format(t))]), 'p', OrderedDict(), | ||
'Hello BlockQuote') | ||
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content) | ||
assert result == expect | ||
|
||
b = Block(t, "bc", "", None, "", 'printf "Hello, World";') | ||
# the content of text will be turned shelved, so we'll asert only the | ||
# deterministic portions of the expected values, below | ||
expect = ('pre', OrderedDict(), 'code', OrderedDict()) | ||
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts) | ||
assert result == expect | ||
|
||
b = Block(t, "h1", "", None, "", "foobar") | ||
expect = ('h1', OrderedDict(), '', OrderedDict(), 'foobar') | ||
result = (b.outer_tag, b.outer_atts, b.inner_tag, b.inner_atts, b.content) | ||
assert result == expect | ||
|
||
def test_block_tags_false(): | ||
t = Textile(block_tags=False) | ||
assert t.block_tags is False | ||
|
||
result = t.parse('test') | ||
expect = 'test' | ||
assert result == expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from textile import Textile | ||
import re | ||
|
||
def test_footnoteRef(): | ||
t = Textile() | ||
result = t.footnoteRef('foo[1]') | ||
expect = 'foo<sup class="footnote" id="fnrev{0}1"><a href="#fn{0}1">1</a></sup>'.format(t.linkPrefix) | ||
assert expect == result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from textile import Textile | ||
|
||
def test_getRefs(): | ||
t = Textile() | ||
result = t.getRefs("some text [Google]http://www.google.com") | ||
expect = 'some text ' | ||
assert result == expect | ||
|
||
result = t.urlrefs | ||
expect = {'Google': 'http://www.google.com'} | ||
assert result == expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from textile.tools.imagesize import getimagesize | ||
import pytest | ||
|
||
PIL = pytest.importorskip('PIL') | ||
|
||
def test_imagesize(): | ||
assert getimagesize("http://www.google.com/intl/en_ALL/images/logo.gif") == (276, 110) | ||
assert getimagesize("http://bad.domain/") == '' | ||
assert getimagesize("http://www.google.com/robots.txt") is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
import textile | ||
|
||
def test_github_issue_16(): | ||
result = textile.textile('"$":http://google.com "$":https://google.com "$":mailto:blackhole@sun.comet') | ||
expect = '\t<p><a href="http://google.com">google.com</a> <a href="https://google.com">google.com</a> <a href="mailto:blackhole%40sun.comet">blackhole@sun.comet</a></p>' | ||
assert result == expect | ||
|
||
def test_github_issue_17(): | ||
result = textile.textile('!http://www.ox.ac.uk/favicon.ico!') | ||
expect = '\t<p><img alt="" src="http://www.ox.ac.uk/favicon.ico" /></p>' | ||
assert result == expect | ||
|
||
def test_github_issue_20(): | ||
text = 'This is a link to a ["Wikipedia article about Textile":http://en.wikipedia.org/wiki/Textile_(markup_language)].' | ||
result = textile.textile(text) | ||
expect = '\t<p>This is a link to a <a href="http://en.wikipedia.org/wiki/Textile_%28markup_language%29">Wikipedia article about Textile</a>.</p>' | ||
assert result == expect | ||
|
||
def test_github_issue_21(): | ||
text = '''h1. xml example | ||
bc. | ||
<foo> | ||
bar | ||
</foo>''' | ||
result = textile.textile(text) | ||
expect = '\t<h1>xml example</h1>\n\n<pre><code>\n<foo>\n bar\n</foo>\n</code></pre>' | ||
assert result == expect | ||
|
||
def test_github_issue_22(): | ||
text = '''_(artist-name)Ty Segall_’s''' | ||
result = textile.textile(text) | ||
expect = '\t<p><em class="artist-name">Ty Segall</em>’s</p>' | ||
assert result == expect | ||
|
||
def test_github_issue_26(): | ||
text = '' | ||
result = textile.textile(text) | ||
expect = '' | ||
assert result == expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from textile import Textile | ||
|
||
def test_glyphs(): | ||
t = Textile() | ||
|
||
result = t.glyphs("apostrophe's") | ||
expect = 'apostrophe’s' | ||
assert result == expect | ||
|
||
result = t.glyphs("back in '88") | ||
expect = 'back in ’88' | ||
assert result == expect | ||
|
||
result = t.glyphs('foo ...') | ||
expect = 'foo …' | ||
assert result == expect | ||
|
||
result = t.glyphs('--') | ||
expect = '—' | ||
assert result == expect | ||
|
||
result = t.glyphs('FooBar[tm]') | ||
expect = 'FooBar™' | ||
assert result == expect | ||
|
||
result = t.glyphs("<p><cite>Cat's Cradle</cite> by Vonnegut</p>") | ||
expect = '<p><cite>Cat’s Cradle</cite> by Vonnegut</p>' | ||
assert result == expect | ||
|
||
result = t.glyphs('test"') | ||
expect = 'test” ' | ||
assert result == expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from textile import Textile | ||
|
||
def test_image(): | ||
t = Textile() | ||
result = t.image('!/imgs/myphoto.jpg!:http://jsamsa.com') | ||
expect = ('<a href="{0}1:url"><img alt="" src="{0}2:url" /></a>'.format( | ||
t.uid)) | ||
assert result == expect | ||
assert t.refCache[1] == 'http://jsamsa.com' | ||
assert t.refCache[2] == '/imgs/myphoto.jpg' | ||
|
||
result = t.image('!</imgs/myphoto.jpg!') | ||
expect = '<img align="left" alt="" src="{0}3:url" />'.format(t.uid) | ||
assert result == expect | ||
assert t.refCache[3] == '/imgs/myphoto.jpg' | ||
|
||
t = Textile(rel='nofollow') | ||
result = t.image('!/imgs/myphoto.jpg!:http://jsamsa.com') | ||
expect = ('<a href="{0}1:url" rel="nofollow"><img alt="" src="{0}2:url" ' | ||
'/></a>'.format(t.uid)) | ||
assert result == expect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import textile | ||
|
||
def test_imagesize(): | ||
imgurl = 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png' | ||
result = textile.tools.imagesize.getimagesize(imgurl) | ||
try: | ||
import PIL | ||
|
||
expect = (275, 95) | ||
assert result == expect | ||
except ImportError: | ||
expect = '' | ||
assert result == expect |
Oops, something went wrong.