Metadata-Version: 2.1
Name: python-textmate
Version: 0.1.2
Summary: TextMate grammar parser for python
License: MIT
Author: Marcel Alexandru Nitan
Author-email: nitan.marcel@protonmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: onigurumacffi (>=1.3.0,<2.0.0)
Description-Content-Type: text/markdown

# TextMate grammar parser for python

## Install

`pip install python-textmate`

## Usage

The parser can parse one line, to parse multiple lines iterate over each line and call parse()

```python
>>> from textmate import TextMateGrammar
>>> import json
>>> code = "print(True) # the parser only parses one line."
>>> with open("MagicPython.tmLanguage.json", "r") as tm:
...     grammar = TextMateGrammar(json.load(tm))
...     print(grammar.parse("print(True)"))
...

[('constant.language.python', (6, 10)),
 ('punctuation.parenthesis.begin.python', (5, 6)),
 ('punctuation.parenthesis.end.python', (10, 11)),
 ('constant.language.python', (6, 10)),
 ('punctuation.definition.arguments.end.python', (10, 11)),
 ('meta.function-call.python', (0, 11)),
 ('keyword.illegal.name.python', (6, 10)),
 ('support.function.builtin.python', (0, 5)),
 ('meta.function-call.generic.python', (0, 5)),
 ('support.function.builtin.python', (0, 5))] 
```
