8000 no space after comma in brackets · matplotlib/matplotlib@1f156be · GitHub
[go: up one dir, main page]

Skip to content

Commit 1f156be

Browse files
committed
no space after comma in brackets
Fixes #5799 Following TeX behaviour: http://www.tex.ac.uk/FAQ-dec_comma.html
1 parent 73f90a2 commit 1f156be

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/matplotlib/mathtext.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,20 @@ def symbol(self, s, loc, toks):
26462646
self._make_space(0.2)] ,
26472647
do_kern = True)]
26482648
elif c in self._punctuation_symbols:
2649+
2650+
# Do not space commas between brackets
2651+
if c == ',':
2652+
for i in six.moves.xrange(1, loc + 1):
2653+
prev_char = s[loc - i]
2654+
if prev_char != ' ':
2655+
break
2656+
for i in six.moves.xrange(1, loc + 1):
2657+
next_char = s[loc + i]
2658+
if next_char != ' ':
2659+
break
2660+
if (prev_char == '{' and next_char == '}'):
2661+
return [char]
2662+
26492663
# Do not space dots as decimal separators
26502664
if (c == '.' and s[loc - 1].isdigit() and s[loc + 1].isdigit()):
26512665
return [char]
@@ -2819,6 +2833,9 @@ def is_slanted(self, nucleus):
28192833
return nucleus.is_slanted()
28202834
return False
28212835

2836+
def is_between_brackets(self, s, loc):
2837+
return False
2838+
28222839
def subsuper(self, s, loc, toks):
28232840
assert(len(toks)==1)
28242841

lib/matplotlib/tests/test_mathtext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
' '.join('$\\' + p + '$' for p in sorted(mathtext.Parser._snowflake)),
106106
r'$6-2$; $-2$; $ -2$; ${-2}$; ${ -2}$; $20^{+3}_{-2}$',
107107
r'$\overline{\omega}^x \frac{1}{2}_0^x$', # github issue #5444
108+
r'$1{,}234{, }567{ , }890$ and $1,234,567,890$', # github issue 5799
108109
]
109110

110111
digits = "0123456789"

0 commit comments

Comments
 (0)
0