diff options
author | Leo Hemsted <leohemsted@gmail.com> | 2017-12-20 13:34:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-20 13:34:39 +0000 |
commit | f55765a6929c981b44622def53038a39e565b6b2 (patch) | |
tree | 4b9a4ea7065c876b7d81774d7661debab8b68621 | |
parent | 655dd138b9592219a0937b83ed76af69d42b1c37 (diff) | |
parent | 4b5ab3344cc88c69c1045e2c488173dfa867bb7f (diff) | |
download | smartypants-git-f55765a6929c981b44622def53038a39e565b6b2.tar.gz |
Merge pull request #2 from leohemsted/regex-match
Use match instead of search.
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | CHANGES.rst | 1 | ||||
-rw-r--r-- | COPYING | 7 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rwxr-xr-x | smartypants | 2 | ||||
-rwxr-xr-x | smartypants.py | 13 | ||||
-rw-r--r-- | tests/test.py | 13 | ||||
-rw-r--r-- | tests/test_cli.py | 2 | ||||
-rw-r--r-- | tests/test_deprecated.py | 2 | ||||
-rw-r--r-- | tests/test_setup.py | 2 |
10 files changed, 37 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00fc953 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +syntax: glob +build +docs/_build +dist +MANIFEST +PKG-INFO +smartypants_command.py +*.pyc diff --git a/CHANGES.rst b/CHANGES.rst index 133dc8c..2627e49 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -46,6 +46,7 @@ Releases 2.0 and greater Development ----------- +* use `re.match` instead of `re.search` to improve performance on large strings Release 2.0.0 (2016-12-28T06:18:42Z) ------------------------------------ @@ -23,7 +23,7 @@ SmartyPants the documentation and/or other materials provided with the distribution. - * Neither the name "SmartyPants" nor the names of its contributors + * Neither the name "SmartyPants" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @@ -46,8 +46,9 @@ smartypants :: smartypants is a derivative work of SmartyPants. - - Copyright (c) 2013, 2014 Yu-Jie Lin + + Copyright (c) 2017, Leo Hemsted + Copyright (c) 2013, 2014, 2015, 2016 Yu-Jie Lin Copyright (c) 2004, 2005, 2007, 2013 Chad Miller Redistribution and use in source and binary forms, with or without @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2013, 2014 by Yu-Jie Lin +# Copyright (C) 2017 by Leo Hemsted # For detail license information, See COPYING from __future__ import print_function diff --git a/smartypants b/smartypants index 189adf5..b5af1c0 100755 --- a/smartypants +++ b/smartypants @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2013, 2014 Yu-Jie Lin +# Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING """ diff --git a/smartypants.py b/smartypants.py index a70575b..c39f409 100755 --- a/smartypants.py +++ b/smartypants.py @@ -1,5 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- +# Copyright (c) 2017 Leo Hemsted # Copyright (c) 2013, 2014, 2016 Yu-Jie Lin # Copyright (c) 2004, 2005, 2007, 2013 Chad Miller # Copyright (c) 2003 John Gruber @@ -12,11 +13,11 @@ smartypants module :func:`smartypants` is the core of smartypants module. """ -__author__ = 'Yu-Jie Lin' -__author_email__ = 'livibetter@gmail.com' -__version__ = '2.0.0' +__author__ = 'Leo Hemsted' +__author_email__ = 'leohemsted@gmail.com' +__version__ = '2.0.1' __license__ = 'BSD License' -__url__ = 'https://bitbucket.org/livibetter/smartypants.py' +__url__ = 'https://github.com/leohemsted/smartypants.py' __description__ = 'Python with the SmartyPants' import re @@ -569,7 +570,7 @@ def _tokenize(text): tag_soup = re.compile(r'([^<]*)(<!--.*?--\s*>|<[^>]*>)', re.S) - token_match = tag_soup.search(text) + token_match = tag_soup.match(text) previous_end = 0 while token_match: @@ -599,7 +600,7 @@ def _tokenize(text): tokens.append([type_, tag]) previous_end = token_match.end() - token_match = tag_soup.search(text, token_match.end()) + token_match = tag_soup.match(text, token_match.end()) if previous_end < len(text): tokens.append(['text', text[previous_end:]]) diff --git a/tests/test.py b/tests/test.py index a16178b..2c1a0ea 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1,10 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2013, 2016 Yu-Jie Lin +# Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING import doctest import unittest +from time import time import smartypants from smartypants import smartypants as sp @@ -147,6 +148,16 @@ document.write('<a href="' + href + '">' + linktext + "</a>"); self.assertEqual(sp('"quote here"', Attr.set1 | Attr.s), '"quote here"') + def test_incredibly_long_string(self): + # make sure it doesn't take too long with a long string + start = time() + + sp("a" * 10000) + + end = time() + + self.assertLess(end - start, 0.2) + def load_tests(loader, tests, pattern): diff --git a/tests/test_cli.py b/tests/test_cli.py index 263f319..e85545a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013 Yu-Jie Lin +# Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING from __future__ import unicode_literals diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 8d4fc7e..0f554e9 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2013, 2016 Yu-Jie Lin +# Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING import unittest diff --git a/tests/test_setup.py b/tests/test_setup.py index e5eb654..20e4678 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2013 Yu-Jie Lin +# Copyright (c) 2017 Leo Hemsted # Licensed under the BSD License, for detailed license information, see COPYING import unittest |