diff options
author | Tim Hatch <tim@timhatch.com> | 2014-04-14 10:58:08 -0400 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-04-14 10:58:08 -0400 |
commit | 16885fe88cd8d74ab9ccb4a53b776e21cf56ded1 (patch) | |
tree | 9ed5e26bb3c56802a3066ee831a96d1c66a0d2aa /pygments/formatters/latex.py | |
parent | f5744a781abb9deb7508118ea0b308cb4724435e (diff) | |
download | pygments-16885fe88cd8d74ab9ccb4a53b776e21cf56ded1.tar.gz |
Merged in protz/pygments-main (pull request #230)
Modified to use simpler checks for string length.
Diffstat (limited to 'pygments/formatters/latex.py')
-rw-r--r-- | pygments/formatters/latex.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py index 61ee0c97..c70dba38 100644 --- a/pygments/formatters/latex.py +++ b/pygments/formatters/latex.py @@ -438,33 +438,33 @@ class LatexEmbededLexer(Lexer): buf = '' for i, t, v in self.lang.get_tokens_unprocessed(text): if t in Token.Comment or t in Token.String: - if len(buf) > 0: + if buf: for x in self.get_tokens_aux(idx, buf): yield x buf = '' yield i, t, v else: - if len(buf) == 0: + if not buf: idx = i; - buf = buf + v - if len(buf) > 0: + buf += v + if buf: for x in self.get_tokens_aux(idx, buf): yield x def get_tokens_aux(self, index, text): - while len(text) > 0: + while text: a, sep1, text = text.partition(self.left) - if len(a) > 0: + if a: for i, t, v in self.lang.get_tokens_unprocessed(a): yield index + i, t, v - index = index + len(a) - if len(sep1) > 0: + index += len(a) + if sep1: b, sep2, text = text.partition(self.right) - if len(sep2) > 0: + if sep2: yield index + len(sep1), Token.Escape, b - index = index + len(sep1) + len(b) + len(sep2) + index += len(sep1) + len(b) + len(sep2) else: yield index, Token.Error, sep1 - index = index + len(sep1) + index += len(sep1) text = b |