(self, s, loc, toks)
| 2623 | return [self._make_space(float(toks[0]))] |
| 2624 | |
| 2625 | def symbol(self, s, loc, toks): |
| 2626 | c = toks[0] |
| 2627 | try: |
| 2628 | char = Char(c, self.get_state()) |
| 2629 | except ValueError: |
| 2630 | raise ParseFatalException(s, loc, "Unknown symbol: %s" % c) |
| 2631 | |
| 2632 | if c in self._spaced_symbols: |
| 2633 | # iterate until we find previous character, needed for cases |
| 2634 | # such as ${ -2}$, $ -2$, or $ -2$. |
| 2635 | prev_char = next((c for c in s[:loc][::-1] if c != ' '), '') |
| 2636 | # Binary operators at start of string should not be spaced |
| 2637 | if (c in self._binary_operators and |
| 2638 | (len(s[:loc].split()) == 0 or prev_char == '{' or |
| 2639 | prev_char in self._left_delim)): |
| 2640 | return [char] |
| 2641 | else: |
| 2642 | return [Hlist([self._make_space(0.2), |
| 2643 | char, |
| 2644 | self._make_space(0.2)] , |
| 2645 | do_kern = True)] |
| 2646 | elif c in self._punctuation_symbols: |
| 2647 | |
| 2648 | # Do not space commas between brackets |
| 2649 | if c == ',': |
| 2650 | prev_char = next((c for c in s[:loc][::-1] if c != ' '), '') |
| 2651 | next_char = next((c for c in s[loc + 1:] if c != ' '), '') |
| 2652 | if prev_char == '{' and next_char == '}': |
| 2653 | return [char] |
| 2654 | |
| 2655 | # Do not space dots as decimal separators |
| 2656 | if c == '.' and s[loc - 1].isdigit() and s[loc + 1].isdigit(): |
| 2657 | return [char] |
| 2658 | else: |
| 2659 | return [Hlist([char, |
| 2660 | self._make_space(0.2)], |
| 2661 | do_kern = True)] |
| 2662 | return [char] |
| 2663 | |
| 2664 | snowflake = symbol |
| 2665 |
no test coverage detected