summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Jie Lin <livibetter@gmail.com>2013-08-18 14:37:29 +0800
committerYu-Jie Lin <livibetter@gmail.com>2013-08-18 14:37:29 +0800
commit6cb3c2168e537df23ab13dcde54d523c1c8fb39c (patch)
tree4f66d069c96d02d0f172604b351ec8ffb6f55a05
parent8141e0b553a39f03af332c58fb78af8eb1b65253 (diff)
downloadsmartypants-6cb3c2168e537df23ab13dcde54d523c1c8fb39c.tar.gz
add --skip to command-line for skipped elements
-rw-r--r--CHANGES.rst4
-rwxr-xr-xsmartypants5
-rw-r--r--tests/test_cli.py20
3 files changed, 28 insertions, 1 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 84a44a2..ea4a6de 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -10,7 +10,9 @@ Versions without timestamps mean they are future releases.
- drop ``smartyPants()``
development:
- - add ``--version``
+ - command-line
+ - add ``--version``
+ - add ``--skip`` for skipped elements
- add Makefile:
- ``test_pep8``, ``test_pyflakes``, and ``test_test`` (unittest)
targets
diff --git a/smartypants b/smartypants
index ad4837b..cb853bf 100755
--- a/smartypants
+++ b/smartypants
@@ -16,6 +16,9 @@ def main():
version=smartypants.__version__)
parser.add_argument('-a', '--attr', default='1',
help='processing attributes (Default: %(default)s)')
+ parser.add_argument('-s', '--skip',
+ default=','.join(smartypants.tags_to_skip),
+ help='processing attributes (Default: %(default)s)')
parser.add_argument('files', metavar='FILE', type=argparse.FileType('r'),
nargs='*', help='files to be processed ')
args = parser.parse_args()
@@ -26,6 +29,8 @@ def main():
print(w[-1].message)
sys.exit(1)
+ smartypants.tags_to_skip = args.skip.split(',')
+
if args.files:
for f in args.files:
print(smartypants.smartypants(f.read(), attr), end='')
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 0cf29dc..69b9e4d 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -48,6 +48,26 @@ class TestCLI(unittest.TestCase):
output = self._p([CLI_SCRIPT, '--attr', 'b'], T)
self.assertEquals(output, E)
+ def test_skipped_elements(self):
+
+ T = '<a>"foo"</a> <b>"bar"</b>'
+
+ E = '<a>&#8220;foo&#8221;</a> <b>&#8220;bar&#8221;</b>'
+ output = self._p([CLI_SCRIPT], T)
+ self.assertEquals(output, E)
+
+ E = '<a>"foo"</a> <b>&#8220;bar&#8221;</b>'
+ output = self._p([CLI_SCRIPT, '--skip', 'a'], T)
+ self.assertEquals(output, E)
+
+ E = '<a>&#8220;foo&#8221;</a> <b>"bar"</b>'
+ output = self._p([CLI_SCRIPT, '--skip', 'b'], T)
+ self.assertEquals(output, E)
+
+ E = T
+ output = self._p([CLI_SCRIPT, '--skip', 'a,b'], T)
+ self.assertEquals(output, E)
+
def test_file(self):
T = '"foobar"'