Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
mathtext: Add-
to spaced symbols, and do not space symbols at start of string#5020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
prev_char = s[loc-i] | ||
while prev_char == ' ' and i <= loc: | ||
i += 1 | ||
prev_char = s[loc-i] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think it would be more pythonic to usesix.xrange
for this loop: i.e.:
for i in six.xrange(1, loc + 1):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Definitely, I wasn't very happy with that loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It will need a break then:
for i in six.moves.xrange(1, loc + 1): prev_char = s[loc-i] if prev_char != ' ': break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, I think that's better.
@mdboom: Anything else that should be changed in this PR? |
No, this looks fine to me. |
mathtext: Add `-` to spaced symbols, and do not space symbols at start of string
PR related to changes in symbol spacing made in#4872. This PR does two things:
-
to set of_binary_operators
that are then considered in_spaced_symbols
, so that-
is spaced equivalently to+
:$1-2$
should be spaced exactly as$1+2$
.-
and+
) is at the start of the string or of a unit delimited by{ }
. This makes things like$+2$
or$21^{+2}_{-3}$
more natural, as the+
or-
are not really a binary operator anymore but part of the number.A test has been added to check for spacing in the second item, so that
$-2$; $ -2$; ${-2}$; ${ -2}$
all render equally, but with different spacing than$6-2$
.attn@mdboom,@tacaswell (also sorry for not catching this in#4872!)