[Python-modules-commits] [python-latexcodec] 03/20: New upstream version 1.0.5

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 13 15:34:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository python-latexcodec.

commit e4f3833d1df83e7d3ca4e657fa8b1ed5597817fd
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Thu Jul 13 11:58:28 2017 +0100

    New upstream version 1.0.5
---
 .travis.yml                              | 29 -------------------
 CHANGELOG.rst                            | 20 +++++++++++--
 INSTALL.rst                              |  2 +-
 PKG-INFO                                 | 41 ++++++++++++++++++++++++++
 VERSION                                  |  2 +-
 debian/changelog                         |  5 ----
 debian/compat                            |  1 -
 debian/control                           | 26 -----------------
 debian/copyright                         | 31 --------------------
 debian/python3-latexcodec.doc-base       |  9 ------
 debian/rules                             | 17 -----------
 debian/source/format                     |  1 -
 debian/source/options                    |  1 -
 debian/watch                             |  3 --
 doc/_build/.gitignore                    |  0
 doc/conf.py                              |  2 +-
 latexcodec.egg-info/PKG-INFO             | 41 ++++++++++++++++++++++++++
 latexcodec.egg-info/SOURCES.txt          | 33 +++++++++++++++++++++
 latexcodec.egg-info/dependency_links.txt |  1 +
 latexcodec.egg-info/requires.txt         |  1 +
 latexcodec.egg-info/top_level.txt        |  1 +
 latexcodec.egg-info/zip-safe             |  1 +
 latexcodec/codec.py                      | 15 ++++++++--
 latexcodec/lexer.py                      |  8 +++---
 setup.cfg                                | 14 ++++++---
 setup.py                                 |  2 ++
 test/test_latex_codec.py                 |  8 ++++++
 test/test_latex_lexer.py                 | 49 +++++++++++++++++++++++---------
 28 files changed, 212 insertions(+), 152 deletions(-)

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index fecde4e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-language: python
-sudo: false
-python:
-  - "3.5"
-  - "3.4"
-  - "3.3"
-  - "2.7"
-  - "2.6"
-  - "pypy"
-branches:
-  only:
-    - develop
-install:
-  - "pip install ."
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install coveralls check-manifest flake8 Sphinx; fi"
-script:
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then check-manifest; fi"
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then flake8; fi"
-  - "pushd doc"
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then make html; fi"
-  - "popd"
-  - "pushd test"
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coverage run --source=latexcodec `type -p nosetests`; fi"
-  - "if [[ $TRAVIS_PYTHON_VERSION != '2.7' ]]; then nosetests; fi"
-  - "popd"
-after_success:
-  - "pushd test"
-  - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls; fi"
-  - "popd"
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 3285149..841cb5e 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,21 @@
-1.0.3 (in development)
-----------------------
+1.0.5 (16 June 2017)
+--------------------
+
+* More maths symbols (naturals, reals, ...).
+
+* Fix lower case z with accents (reported by AndrewSwann, see issue #51).
+
+1.0.4 (21 September 2016)
+-------------------------
+
+* Fix encoding and decoding of percent sign (reported by jgosmann, see
+  issue #48).
+
+1.0.3 (26 March 2016)
+---------------------
+
+* New ``'keep'`` error for the ulatex encoder to keep unicode characters
+  that cannot be translated (contributed by xuhdev, see pull requestion #45).
 
 1.0.2 (1 March 2016)
 --------------------
diff --git a/INSTALL.rst b/INSTALL.rst
index d3ceffa..8927b94 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -54,7 +54,7 @@ as possible of the original code when encoding fails. If instead you
 want to translate to LaTeX but keep as much of the unicode as
 possible, use the ``ulatex+utf8`` codec, which should never fail.
 
-.. code-block::
+.. code-block:: python
 
     import codecs
     import latexcodec
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..fa2af1b
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,41 @@
+Metadata-Version: 1.1
+Name: latexcodec
+Version: 1.0.5
+Summary: A lexer and codec to work with LaTeX code in Python.
+Home-page: https://github.com/mcmtroffaes/latexcodec
+Author: Matthias C. M. Troffaes
+Author-email: matthias.troffaes at gmail.com
+License: MIT
+Download-URL: http://pypi.python.org/pypi/latexcodec
+Description: * Download: http://pypi.python.org/pypi/latexcodec/#downloads
+        
+        * Documentation: http://latexcodec.readthedocs.org/
+        
+        * Development: http://github.com/mcmtroffaes/latexcodec/
+        
+        .. |travis| image:: https://travis-ci.org/mcmtroffaes/latexcodec.png?branch=develop
+            :target: https://travis-ci.org/mcmtroffaes/latexcodec
+            :alt: travis-ci
+        
+        .. |coveralls| image:: https://coveralls.io/repos/mcmtroffaes/latexcodec/badge.png?branch=develop
+            :target: https://coveralls.io/r/mcmtroffaes/latexcodec?branch=develop
+            :alt: coveralls.io
+        
+        
+Platform: any
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Topic :: Text Processing :: Markup :: LaTeX
+Classifier: Topic :: Text Processing :: Filters
diff --git a/VERSION b/VERSION
index 3033bf2..90a27f9 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.3a0
+1.0.5
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index f8d8c00..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,5 +0,0 @@
-python-latexcodec (1.0.3-1) UNRELEASED; urgency=medium
-
-  * Initial release (Closes: #801309).
-
- -- Daniel Stender <stender at debian.org>  Mon, 09 May 2016 12:03:38 +0200
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index ec63514..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/debian/control b/debian/control
deleted file mode 100644
index ed48d81..0000000
--- a/debian/control
+++ /dev/null
@@ -1,26 +0,0 @@
-Source: python-latexcodec
-Section: python
-Priority: optional
-Maintainer: Debian Python Modules Team <python-modules-team at lists.alioth.debian.org>
-Uploaders: Daniel Stender <stender at debian.org>
-Build-Depends: debhelper (>= 9),
-               dh-python,
-               python3-all,
-               python3-six,
-               python3-setuptools,
-               python3-nose,
-               python-sphinx
-# needs fix: build breaks with python3-sphinx
-Standards-Version: 3.9.8
-Homepage: https://github.com/mcmtroffaes/latexcodec
-Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/python-latexcodec.git
-Vcs-Browser: https://anonscm.debian.org/cgit/python-modules/packages/python-latexcodec.git
-X-Python-Version: >= 3.3
-
-Package: python3-latexcodec
-Architecture: all
-Depends: ${misc:Depends},
-         ${python3:Depends},
-         ${sphinxdoc:Depends}
-Description: LaTeX lexer and codec library for Python
- Hello, world!
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index c982dbe..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,31 +0,0 @@
-Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
-Upstream-Name: latexcodec
-Upstream-Contact: Matthias C. M. Troffaes <matthias.troffaes at gmail.com>
-Source: https://github.com/mcmtroffaes/latexcodec
-
-Files: *
-Copyright: 2011-2016 Matthias C. M. Troffaes <matthias.troffaes at gmail.com>
-                     David Eppstein
-                     Peter Tröger
-License: Expat
-
-Files: debian/*
-Copyright: 2016 Daniel Stender <stender at debian.org>
-License: Expat
-
-License: Expat
- Permission is hereby granted, free of charge, to any person obtaining a copy of this
- software and associated documentation files (the "Software"), to deal in the Software
- without restriction, including without limitation the rights to use, copy, modify, merge,
- publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
- to whom the Software is furnished to do so, subject to the following conditions:
- .
- The above copyright notice and this permission notice shall be included in all copies or
- substantial portions of the Software.
- .
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- DEALINGS IN THE SOFTWARE.
diff --git a/debian/python3-latexcodec.doc-base b/debian/python3-latexcodec.doc-base
deleted file mode 100644
index e5f7484..0000000
--- a/debian/python3-latexcodec.doc-base
+++ /dev/null
@@ -1,9 +0,0 @@
-Document: python3-latexcodec
-Title: latexcodec's documentation
-Author: Matthias C. M. Troffaes <matthias.troffaes at gmail.com>
-Abstract: latexcodec is a LaTeX lexer and codec library for Python
-Section: Programming/Python
-
-Format: HTML
-Index: /usr/share/doc/python3-latexcodec/html/index.html
-Files: /usr/share/doc/python3-latexcodec/html/*.html
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index d49cd0e..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/make -f
-#export DH_VERBOSE=1
-#export DEB_BUILD_OPTIONS=nocheck
-export PYBUILD_NAME=latexcodec
-
-%:
-	dh $@ --with python3,sphinxdoc --buildsystem=pybuild
-
-override_dh_auto_test:
-	PYBUILD_SYSTEM=custom PYBUILD_TEST_ARGS="{interpreter} -m nose -v" dh_auto_test
-
-override_dh_installdocs:
-	dh_installdocs
-	PYTHONPATH=. sphinx-build -N -bhtml doc/ debian/python3-latexcodec/usr/share/doc/python3-latexcodec/html/
-
-override_dh_installchangelogs:
-	dh_installchangelogs CHANGELOG.rst
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/source/options b/debian/source/options
deleted file mode 100644
index 6e88e49..0000000
--- a/debian/source/options
+++ /dev/null
@@ -1 +0,0 @@
-extend-diff-ignore="^[^/]+\.egg-info/"
\ No newline at end of file
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index d5cfe7a..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,3 +0,0 @@
-version=3
-opts="filenamemangle=s/(?:.*)?v?(\d[\d\.]+)\.tar\.gz/python-latexcodec-$1.tar.gz/" \
-https://github.com/mcmtroffaes/latexcodec/releases (?:.*/)?v?(\d[\d\.]+)\.tar\.gz
diff --git a/doc/_build/.gitignore b/doc/_build/.gitignore
deleted file mode 100644
index e69de29..0000000
diff --git a/doc/conf.py b/doc/conf.py
index 0f3942f..8794e64 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -9,7 +9,7 @@ extensions = [
     'sphinx.ext.intersphinx',
     'sphinx.ext.todo',
     'sphinx.ext.coverage',
-    'sphinx.ext.pngmath',
+    'sphinx.ext.imgmath',
     'sphinx.ext.viewcode']
 source_suffix = '.rst'
 master_doc = 'index'
diff --git a/latexcodec.egg-info/PKG-INFO b/latexcodec.egg-info/PKG-INFO
new file mode 100644
index 0000000..fa2af1b
--- /dev/null
+++ b/latexcodec.egg-info/PKG-INFO
@@ -0,0 +1,41 @@
+Metadata-Version: 1.1
+Name: latexcodec
+Version: 1.0.5
+Summary: A lexer and codec to work with LaTeX code in Python.
+Home-page: https://github.com/mcmtroffaes/latexcodec
+Author: Matthias C. M. Troffaes
+Author-email: matthias.troffaes at gmail.com
+License: MIT
+Download-URL: http://pypi.python.org/pypi/latexcodec
+Description: * Download: http://pypi.python.org/pypi/latexcodec/#downloads
+        
+        * Documentation: http://latexcodec.readthedocs.org/
+        
+        * Development: http://github.com/mcmtroffaes/latexcodec/
+        
+        .. |travis| image:: https://travis-ci.org/mcmtroffaes/latexcodec.png?branch=develop
+            :target: https://travis-ci.org/mcmtroffaes/latexcodec
+            :alt: travis-ci
+        
+        .. |coveralls| image:: https://coveralls.io/repos/mcmtroffaes/latexcodec/badge.png?branch=develop
+            :target: https://coveralls.io/r/mcmtroffaes/latexcodec?branch=develop
+            :alt: coveralls.io
+        
+        
+Platform: any
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Topic :: Text Processing :: Markup :: LaTeX
+Classifier: Topic :: Text Processing :: Filters
diff --git a/latexcodec.egg-info/SOURCES.txt b/latexcodec.egg-info/SOURCES.txt
new file mode 100644
index 0000000..3874c0a
--- /dev/null
+++ b/latexcodec.egg-info/SOURCES.txt
@@ -0,0 +1,33 @@
+AUTHORS.rst
+CHANGELOG.rst
+INSTALL.rst
+LICENSE.rst
+MANIFEST.in
+README.rst
+VERSION
+requirements.txt
+setup.cfg
+setup.py
+doc/Makefile
+doc/api.rst
+doc/authors.rst
+doc/changes.rst
+doc/conf.py
+doc/index.rst
+doc/license.rst
+doc/make.bat
+doc/quickstart.rst
+doc/api/codec.rst
+doc/api/lexer.rst
+latexcodec/__init__.py
+latexcodec/codec.py
+latexcodec/lexer.py
+latexcodec.egg-info/PKG-INFO
+latexcodec.egg-info/SOURCES.txt
+latexcodec.egg-info/dependency_links.txt
+latexcodec.egg-info/requires.txt
+latexcodec.egg-info/top_level.txt
+latexcodec.egg-info/zip-safe
+test/test_install_example.py
+test/test_latex_codec.py
+test/test_latex_lexer.py
\ No newline at end of file
diff --git a/latexcodec.egg-info/dependency_links.txt b/latexcodec.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/latexcodec.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/latexcodec.egg-info/requires.txt b/latexcodec.egg-info/requires.txt
new file mode 100644
index 0000000..58b77b6
--- /dev/null
+++ b/latexcodec.egg-info/requires.txt
@@ -0,0 +1 @@
+six>=1.4.1
diff --git a/latexcodec.egg-info/top_level.txt b/latexcodec.egg-info/top_level.txt
new file mode 100644
index 0000000..830df7c
--- /dev/null
+++ b/latexcodec.egg-info/top_level.txt
@@ -0,0 +1 @@
+latexcodec
diff --git a/latexcodec.egg-info/zip-safe b/latexcodec.egg-info/zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/latexcodec.egg-info/zip-safe
@@ -0,0 +1 @@
+
diff --git a/latexcodec/codec.py b/latexcodec/codec.py
index 498e274..649b57d 100644
--- a/latexcodec/codec.py
+++ b/latexcodec/codec.py
@@ -103,6 +103,7 @@ class LatexUnicodeTable:
         self.register(u'\n\n', b' \\par', encode=False)
         self.register(u'\n\n', b'\\par', encode=False)
         self.register(u' ', b'\\ ', encode=False)
+        self.register(u'%', b'\\%')
         self.register(u'\N{EN DASH}', b'--')
         self.register(u'\N{EN DASH}', b'\\textendash')
         self.register(u'\N{EM DASH}', b'---')
@@ -363,9 +364,9 @@ class LatexUnicodeTable:
         self.register(u'\N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}', b'\\^y')
         self.register(u'\N{LATIN CAPITAL LETTER Y WITH DIAERESIS}', b'\\"Y')
         self.register(u'\N{LATIN CAPITAL LETTER Z WITH ACUTE}', b"\\'Z")
-        self.register(u'\N{LATIN SMALL LETTER Z WITH ACUTE}', b"\\'Z")
+        self.register(u'\N{LATIN SMALL LETTER Z WITH ACUTE}', b"\\'z")
         self.register(u'\N{LATIN CAPITAL LETTER Z WITH DOT ABOVE}', b'\\.Z')
-        self.register(u'\N{LATIN SMALL LETTER Z WITH DOT ABOVE}', b'\\.Z')
+        self.register(u'\N{LATIN SMALL LETTER Z WITH DOT ABOVE}', b'\\.z')
         self.register(u'\N{LATIN CAPITAL LETTER Z WITH CARON}', b'\\v Z')
         self.register(u'\N{LATIN SMALL LETTER Z WITH CARON}', b'\\v z')
         self.register(u'\N{LATIN CAPITAL LETTER DZ WITH CARON}', b'D\\v Z')
@@ -558,6 +559,16 @@ class LatexUnicodeTable:
         # match the full latex string... so decoding disabled for now
         self.register(u'Ǭ', br'\textogonekcentered{\=O}', decode=False)
         self.register(u'ǭ', br'\textogonekcentered{\=o}', decode=False)
+        self.register(u'ℕ', br'\mathbb{N}', mode='math')
+        self.register(u'ℕ', br'\mathbb N', mode='math', decode=False)
+        self.register(u'ℤ', br'\mathbb{Z}', mode='math')
+        self.register(u'ℤ', br'\mathbb Z', mode='math', decode=False)
+        self.register(u'ℚ', br'\mathbb{Q}', mode='math')
+        self.register(u'ℚ', br'\mathbb Q', mode='math', decode=False)
+        self.register(u'ℝ', br'\mathbb{R}', mode='math')
+        self.register(u'ℝ', br'\mathbb R', mode='math', decode=False)
+        self.register(u'ℂ', br'\mathbb{C}', mode='math')
+        self.register(u'ℂ', br'\mathbb C', mode='math', decode=False)
 
     def register(self, unicode_text, latex_text, mode='text', package=None,
                  decode=True, encode=True):
diff --git a/latexcodec/lexer.py b/latexcodec/lexer.py
index 1474f94..dd292c1 100644
--- a/latexcodec/lexer.py
+++ b/latexcodec/lexer.py
@@ -167,7 +167,7 @@ class LatexLexer(RegexpLexer):
     # implementation note: every token **must** be decodable by inputenc
     tokens = (
         # comment: for ease, and for speed, we handle it as a token
-        (u'comment', br'%.*?\n'),
+        (u'comment', br'(?<![\\])%[^\n]*'),
         # control tokens
         # in latex, some control tokens skip following whitespace
         # ('control-word' and 'control-symbol')
@@ -304,9 +304,9 @@ class LatexIncrementalLexer(LatexLexer):
                 self.state = 'M'
                 yield token
             elif token.name == 'comment':
-                # go to newline mode, no token is generated
-                # note: comment includes the newline
-                self.state = 'N'
+                # no token is generated
+                # note: comment does not include the newline
+                self.state = 'S'
             elif token.name == 'chars':
                 self.state = 'M'
                 yield token
diff --git a/setup.cfg b/setup.cfg
index 85ffac4..37a3824 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,14 @@
 [nosetests]
-with-coverage=1
-cover-package=latexcodec
-cover-branches=1
-cover-html=1
+with-coverage = 1
+cover-package = latexcodec
+cover-branches = 1
+cover-html = 1
 
 [wheel]
 universal = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+tag_svn_revision = 0
+
diff --git a/setup.py b/setup.py
index fb0b7c9..6f92340 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@ def readfile(filename):
     with io.open(filename, encoding="utf-8") as stream:
         return stream.read().split("\n")
 
+
 readme = readfile("README.rst")[5:]  # skip title and badges
 requires = readfile("requirements.txt")
 version = readfile("VERSION")[0].strip()
@@ -37,6 +38,7 @@ setup(
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Topic :: Text Processing :: Markup :: LaTeX',
         'Topic :: Text Processing :: Filters',
     ],
diff --git a/test/test_latex_codec.py b/test/test_latex_codec.py
index fc7f8bf..9cbfb6e 100644
--- a/test/test_latex_codec.py
+++ b/test/test_latex_codec.py
@@ -198,6 +198,10 @@ class TestDecoder(TestCase):
         self.decode(u'This is a \\ \\test.',
                     br'This is a $\backslash$ \textbackslash test.')
 
+    def test_percent(self):
+        self.decode(u'This is a % test.',
+                    br'This is a \% test.')
+
 
 class TestStreamDecoder(TestDecoder):
 
@@ -367,6 +371,10 @@ class TestEncoder(TestCase):
                     (br'This is a \~{}, \texttildelow , '
                      br'$\sim$ and \textasciitilde test.'))
 
+    def test_percent(self):
+        self.encode(u'This is a % test.',
+                    br'This is a \% test.')
+
 
 class TestStreamEncoder(TestEncoder):
 
diff --git a/test/test_latex_lexer.py b/test/test_latex_lexer.py
index 8d3a75f..e95b797 100644
--- a/test/test_latex_lexer.py
+++ b/test/test_latex_lexer.py
@@ -13,6 +13,20 @@ from latexcodec.lexer import (
     Token)
 
 
+class MockLexer(LatexLexer):
+    tokens = (
+        (u'chars', br'mock'),
+        (u'unknown', br'.'),
+        )
+
+
+class MockIncrementalDecoder(LatexIncrementalDecoder):
+    tokens = (
+        (u'chars', br'mock'),
+        (u'unknown', br'.'),
+        )
+
+
 def test_token_create_with_args():
     t = Token('hello', b'world')
     nose.tools.assert_equal(t.name, 'hello')
@@ -78,14 +92,14 @@ class LatexLexerTest(BaseLatexLexerTest):
     def test_comment(self):
         self.lex_it(
             b'test% some comment\ntest',
-            b't|e|s|t|% some comment\n|t|e|s|t'.split(b'|'),
+            b't|e|s|t|% some comment|\n|t|e|s|t'.split(b'|'),
             final=True
         )
 
     def test_comment_newline(self):
         self.lex_it(
             b'test% some comment\n\ntest',
-            b't|e|s|t|% some comment\n|\n|t|e|s|t'.split(b'|'),
+            b't|e|s|t|% some comment|\n|\n|t|e|s|t'.split(b'|'),
             final=True
         )
 
@@ -171,6 +185,15 @@ class LatexLexerTest(BaseLatexLexerTest):
     def test_tab(self):
         self.lex_it(b'\c\tc', b'\c|\t|c'.split(b'|'), final=True)
 
+    def test_percent(self):
+        self.lex_it(b'This is a \\% test.',
+                    b'T|h|i|s| |i|s| |a| |\\%| |t|e|s|t|.'.split(b'|'),
+                    final=True)
+        self.lex_it(b'\\% %test',
+                    b'\\%| |%test'.split(b'|'), final=True)
+        self.lex_it(b'\\% %test\nhi',
+                    b'\\%| |%test|\n|h|i'.split(b'|'), final=True)
+
 
 class UnicodeLatexLexerTest(LatexLexerTest):
     Lexer = UnicodeLatexLexer
@@ -335,12 +358,10 @@ class LatexIncrementalDecoderTest(BaseLatexIncrementalDecoderTest):
             final=True
         )
 
-    # counterintuitive?
-    @nose.tools.raises(UnicodeDecodeError)
     def test_final_comment(self):
         self.lex_it(
             b'hello%',
-            [b'hello'],
+            b'h|e|l|l|o'.split(b'|'),
             final=True
         )
 
@@ -358,12 +379,12 @@ class UnicodeLatexIncrementalDecoderTest(LatexIncrementalDecoderTest):
 class LatexIncrementalDecoderReplaceTest(BaseLatexIncrementalDecoderTest):
 
     errors = 'replace'
-    IncrementalDecoder = LatexIncrementalDecoder
+    IncrementalDecoder = MockIncrementalDecoder
 
     def test_errors_replace(self):
         self.lex_it(
-            b'hello%',
-            b'h|e|l|l|o|?'.split(b'|'),
+            b'helmocklo',
+            b'?|?|?|mock|?|?'.split(b'|'),
             final=True
         )
 
@@ -371,12 +392,12 @@ class LatexIncrementalDecoderReplaceTest(BaseLatexIncrementalDecoderTest):
 class LatexIncrementalDecoderIgnoreTest(BaseLatexIncrementalDecoderTest):
 
     errors = 'ignore'
-    IncrementalDecoder = LatexIncrementalDecoder
+    IncrementalDecoder = MockIncrementalDecoder
 
     def test_errors_ignore(self):
         self.lex_it(
-            b'hello%',
-            b'h|e|l|l|o'.split(b'|'),
+            b'helmocklo',
+            b'mock'.split(b'|'),
             final=True
         )
 
@@ -384,13 +405,13 @@ class LatexIncrementalDecoderIgnoreTest(BaseLatexIncrementalDecoderTest):
 class LatexIncrementalDecoderInvalidErrorTest(BaseLatexIncrementalDecoderTest):
 
     errors = '**baderror**'
-    IncrementalDecoder = LatexIncrementalDecoder
+    IncrementalDecoder = MockIncrementalDecoder
 
     @nose.tools.raises(NotImplementedError)
     def test_errors_invalid(self):
         self.lex_it(
-            b'hello%',
-            b'h|e|l|l|o'.split(b'|'),
+            b'helmocklo',
+            b'?|?|?|mock|?|?'.split(b'|'),
             final=True
         )
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-latexcodec.git



More information about the Python-modules-commits mailing list