Skip to content

Commit

Permalink
Remove validation code.
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtraschke committed Sep 7, 2009
1 parent 9c3c563 commit c028908
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
7 changes: 0 additions & 7 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

* Improve test coverage (use coverage stats in docs/coverage/index.html).

* Consider stripping out HTML validation code.
Validation is also not a concern of a text formatting library;
with restricted=True, Textile _should_ produce valid HTML or XHTML.
If user-generated HTML is allowed (as is the case when restricted=False,
the default), then all bets are off. Genshi or lxml with BeautifulSoup
can generally do something useful with user-provided tag soup.

* Improve documentation, both of the code and Textile syntax.
The previous version of pytextile had excellent inline documentation;
similarly, docstrings such as "What does this do?" should be improved.
41 changes: 1 addition & 40 deletions textile/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,6 @@ def getimagesize(url):
except (IOError, ValueError):
return None

# PyTextile can optionally validate the generated
# XHTML code using either mxTidy or uTidyLib.
try:
# This is mxTidy.
from mx.Tidy import Tidy

def _tidy1(text):
"""mxTidy's XHTML validator.
This function is a wrapper to mxTidy's validator.
"""
nerrors, nwarnings, text, errortext = Tidy.tidy(text, output_xhtml=1, numeric_entities=1, wrap=0)
return _in_tag(text, 'body')

_tidy = _tidy1

except ImportError:
try:
# This is uTidyLib.
import tidy

def _tidy2(text):
"""uTidyLib's XHTML validator.
This function is a wrapper to uTidyLib's validator.
"""
text = tidy.parseString(text, output_xhtml=1, add_xml_decl=0, indent=0, tidy_mark=0)
return _in_tag(str(text), 'body')

_tidy = _tidy2

except ImportError:
_tidy = None

class Textile(object):
hlgn = r'(?:\<(?!>)|(?<!<)\>|\<\>|\=|[()]+(?! ))'
vlgn = r'[\-^~]'
Expand Down Expand Up @@ -182,7 +148,7 @@ def __init__(self, restricted=False, lite=False, noimage=False):
self.rel = ''
self.html_type = 'xhtml'

def textile(self, text, rel=None, validate=False, head_offset=0, html_type='xhtml'):
def textile(self, text, rel=None, head_offset=0, html_type='xhtml'):
"""
>>> import textile
>>> textile.textile('some textile')
Expand All @@ -205,11 +171,6 @@ def textile(self, text, rel=None, validate=False, head_offset=0, html_type='xhtm

text = self.retrieve(text)


# Validate output.
if _tidy and validate:
text = _tidy(text)

return text

def pba(self, input, element=None):
Expand Down

0 comments on commit c028908

Please sign in to comment.