Skip to main content

tmengine: A TextMate grammar engine in Python.

Installation

python -m pip install tmengine
# or
python -m pip install git+https://github.com/AaravMalani/tmengine

Usage

from tmengine import TextMateEngine
import json

engine = TextMateEngine.load_folder('grammars/') # Load all grammars in the grammars/ folder
print(engine.languages) # Returns a tuple of scopeNames
print(engine.parse('source.akbs', 'compile($FILES)')) # Parse 'compile($FILES)' using language with `scopeName` as `source.akbs` 
# [TextMateExpression(name='punctuation.paren.open', range=(7, 8)), TextMateExpression(name='expression.group', range=(7, 15)), TextMateExpression(name='keyword.function', range=(0, 7)), TextMateExpression(name='expression.inner', range=(8, 14)), TextMateExpression(name='punctuation.paren.close', range=(14, 15)), TextMateExpression(name='variable.other', range=(8, 14))]

with open('grammars/akbs.json', 'r') as f: # Found at https://github.com/akbs-org/akbs-vscode/blob/main/syntaxes/akbs.tmGrammar.json
    engine2 = TextMateEngine(json.load(f)) # or tmengine.TextMateEngine([json.load(f)])

Tasklist

  • Accept YAML
  • Accept XML
  • Make code ignore errors

Changelog

Version 1.0.1

  • Fixed bug which returned indices/a range less than expected when there were multiple match expressions satisfied on separate lines
  • Fixed only a single begin/end expression of a type being selected

Release files for tmengine 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tmengine 1.0.1
File Size Uploaded
tmengine-1.0.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tmengine 1.0.1
File Interpreter ABI Platform
tmengine-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / tmengine-1.0.1.tar.gz

Download URL tmengine-1.0.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a32539cbf1ffe31212ba3629255d4ceb9e1ca7fc48f16517aa7dfc456a7043e2
BLAKE2b-256 checksum
How to use checksums
532c4b93074c90dd1869be6142c60abf91a12d3a4ff06a9a3491e172af42c9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / tmengine-1.0.1-py3-none-any.whl

Download URL tmengine-1.0.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
846b845e20c591fcef00bc3d909d301add6ffe35bc2a4ef9f27543834d118a48
BLAKE2b-256 checksum
How to use checksums
30df823fa361c0990aacb3b4ea2bc13e4ac1f9600398f37ea5078c7bf715c8ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page