commands.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python
  2. # __author__ = "Ronie Martinez"
  3. # __copyright__ = "Copyright 2016-2019, Ronie Martinez"
  4. # __credits__ = ["Ronie Martinez"]
  5. # __license__ = "MIT"
  6. # __maintainer__ = "Ronie Martinez"
  7. # __email__ = "ronmarti18@gmail.com"
  8. MATRICES = (
  9. r'\matrix', r'\matrix*',
  10. r'\pmatrix', r'\pmatrix*',
  11. r'\bmatrix', r'\bmatrix*',
  12. r'\Bmatrix', r'\Bmatrix*',
  13. r'\vmatrix', r'\vmatrix*',
  14. r'\Vmatrix', r'\Vmatrix*',
  15. r'\array'
  16. )
  17. SPACES = (r'\,', r'\:', r'\;', '\\', r'\quad', r'\qquad')
  18. COMMANDS = {
  19. # command: (params_count, mathml_equivalent, attributes)
  20. '_': (2, 'msub', {}),
  21. '^': (2, 'msup', {}),
  22. '_^': (3, 'msubsup', {}),
  23. r'\frac': (2, 'mfrac', {}),
  24. # r'\lg': (1, 'mlg', {}),
  25. # r'\ln': (1, 'mln', {}),
  26. r'\text': (1, 'mtext', {}),
  27. r'\sqrt': (1, 'msqrt', {}),
  28. r'\root': (2, 'mroot', {}),
  29. r'\binom': (2, 'mfrac', {'linethickness': '0'}),
  30. r'\left': (1, 'mo', {'stretchy': 'true', 'fence': 'true', 'form': 'prefix'}),
  31. r'\right': (1, 'mo', {'stretchy': 'true', 'fence': 'true', 'form': 'postfix'}),
  32. r'\overline': (1, 'mover', {}),
  33. r'\underline': (1, 'munder', {}),
  34. r'\overrightarrow': (1, 'mover', {}),
  35. r'\overrightarrowm': (1, 'mover', {}),
  36. # r'\overline': (1, 'mover', {}),
  37. }
  38. for space in SPACES:
  39. COMMANDS[space] = (0, 'mspace', {'width': '0.167em'})
  40. for matrix in MATRICES:
  41. COMMANDS[matrix] = (1, 'mtable', {})