Skip to content

Commit

Permalink
Merge branch 'release/2.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ikirudennis committed May 10, 2016
2 parents c109627 + 290f5d7 commit b2ce863
Show file tree
Hide file tree
Showing 40 changed files with 2,312 additions and 1,857 deletions.
7 changes: 7 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[run]
branch = True

[report]
show_missing = True
omit =
textile/tests/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
*~
*.pyo
*.egg-info
.cache/
.coverage
.eggs/
.noseids*
docs/build
docs/coverage
build
bin
dist
eggs
htmlcov
parts
develop-eggs
.DS_Store
Expand Down
18 changes: 14 additions & 4 deletions .travis.yml
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
25 changes: 22 additions & 3 deletions CHANGELOG.textile
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
12 changes: 7 additions & 5 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
!https://travis-ci.org/textile/python-textile.svg?branch=develop!:https://travis-ci.org/textile/python-textile
!https://travis-ci.org/textile/python-textile.svg!:https://travis-ci.org/textile/python-textile !https://coveralls.io/repos/github/textile/python-textile/badge.svg!:https://coveralls.io/github/textile/python-textile?branch=master !https://codecov.io/github/textile/python-textile/coverage.svg!:https://codecov.io/github/textile/python-textile

h1. python-textile

python-textile is a Python port of Textile, Dean Allen's humane web text generator.
python-textile is a Python port of "Textile":http://txstyle.org/, Dean Allen's humane web text generator.

h2. Installation

Install the 'textile' folder on your python path, or @pip install textile@.
Optional dependencies include PIL/Pillow (for checking images size)
and regex (for faster unicode-aware string matching).
@pip install textile@

Optional dependencies include:
* "PIL/Pillow":http://python-pillow.github.io/ (for checking images size)
* "regex":https://pypi.python.org/pypi/regex (for faster unicode-aware string matching).

h2. Usage

Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
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
4 changes: 1 addition & 3 deletions requirements.txt
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
9 changes: 2 additions & 7 deletions setup.cfg
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
26 changes: 14 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
import os
import sys

install_requires = []


if 'develop' in sys.argv:
install_requires.extend([
'tox',
])

def get_version():
basedir = os.path.dirname(__file__)
with open(os.path.join(basedir, 'textile/version.py')) as f:
Expand All @@ -32,14 +24,24 @@ def get_version():
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
keywords='textile,text',
install_requires=install_requires,
keywords='textile,text,html markup',
install_requires=['six',],
extras_require={
':python_version=="2.6"': ['ordereddict>=1.1'],
'develop': ['regex', 'pytest', 'pytest-cov'],
},
test_suite='nose.collector',
tests_require=['nose'],
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-cov'],
include_package_data=True,
zip_safe=False,
)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_attributes.py
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'}
49 changes: 49 additions & 0 deletions tests/test_block.py
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
8 changes: 8 additions & 0 deletions tests/test_footnoteRef.py
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
11 changes: 11 additions & 0 deletions tests/test_getRefs.py
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
9 changes: 9 additions & 0 deletions tests/test_getimagesize.py
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
43 changes: 43 additions & 0 deletions tests/test_github_issues.py
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&lt;foo&gt;\n bar\n&lt;/foo&gt;\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
32 changes: 32 additions & 0 deletions tests/test_glyphs.py
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&#8217;s'
assert result == expect

result = t.glyphs("back in '88")
expect = 'back in &#8217;88'
assert result == expect

result = t.glyphs('foo ...')
expect = 'foo &#8230;'
assert result == expect

result = t.glyphs('--')
expect = '&#8212;'
assert result == expect

result = t.glyphs('FooBar[tm]')
expect = 'FooBar&#8482;'
assert result == expect

result = t.glyphs("<p><cite>Cat's Cradle</cite> by Vonnegut</p>")
expect = '<p><cite>Cat&#8217;s Cradle</cite> by Vonnegut</p>'
assert result == expect

result = t.glyphs('test"')
expect = 'test&#8221; '
assert result == expect
21 changes: 21 additions & 0 deletions tests/test_image.py
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
13 changes: 13 additions & 0 deletions tests/test_imagesize.py
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
Loading

0 comments on commit b2ce863

Please sign in to comment.