Mathpix / mathpix-markdown-it

Markdown rendering + Latex extras (equations, tables, ...), with conversion features, for the scientific community
MIT License
465 stars 42 forks source link

PR into master from dev/olga/7982-Random-MMD-converter-test-failures #300

Closed OlgaRedozubova closed 5 months ago

OlgaRedozubova commented 5 months ago

branch: dev/olga/7982-Random-MMD-converter-test-failures

Using

const id = `f${(+new Date + (Math.random()*100000).toFixed()).toString()}`;

Does not guarantee a unique id A situation may arise when two identical IDs are generated For example:

  {
    "id": "f170551290225270915",
    "content": "\\( \\$ 820,000 \\)"
  },
  {
    "id": "f170551290225270915",
    "content": "\\( \\$ 716,000 \\)"
  }

This results in an error

      + expected - actual

       | Inventory | $\$ 140,000$ | $\$ 120,000$ | $\$ 96,000$ |
       | Total current assets | $\$ 180,000$ | $\$ 170,000$ | $\$ 128,000$ |
       | Non Current assets | $\$ 440,000$ | $\$ 370,000$ | $\$ 260,000$ |
       | Plant and equipment (net) |  |  |  |
      -| Investments | $\$ 1,000,000$ | $\$ 820,000$ | $\$ 820,000$ |
      +| Investments | $\$ 1,000,000$ | $\$ 820,000$ | $\$ 716,000$ |

Solution

To generate a unique id use f${uuidv4()}