3b1b / 3b1b/manim

`get_parts_by_tex` return wrong SVG element

Offen
#2,367 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
93.8k
Forks
7.7k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

### Describe the bug
When I try to grab an element from a fraction with `get_parts_by_tex`, there's an off by one error

**Code**:
```python
from manimlib import *

class Test(Scene):
def construct(self):
s = Tex(r"\frac{ 1 }{ 2 }")
s.get_parts_by_tex(r"1").set_color(GREEN)
self.add(s)

```

**Wrong display or Error traceback**:

Image

### Additional context
I think this is because there's a mismatch between the order of the Tex commands vs the order of the svg elements.
- `tex_commands = ["\\frac", "1", "2"]`
- `get_parts_by_tex(1)` points to idx value 1 (because "1" is second element in `tex_commands`)
- `svg_map = ["1", "/", "2"]` (idx value 1 returns the "/")

We need a way to tell `manim` that when it sees `\frac`, to make sure the items in the numerator come before the "/"

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.