Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working now #1

Merged
merged 3 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2023.08.25124909'
__version__ = '2023.08.26000000'
50 changes: 50 additions & 0 deletions pyproject.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = [
"hatchling",
"setuptools",
"setuptools_scm[toml]>=6.0",
"build",
"hatch-requirements-txt"
]
build-backend = "hatchling.build"

[project]
name = "pygments_tsx"
license = "MIT"
authors = [
{ name="Jason Nichols", email="github@startupos.dev" },
{ name="Sean Conrad", email="github@startupos.dev"}
]
description = "A plugin for adding TSX support to Pygments based off the work of the JSX plugin."
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: JavaScript",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Topic :: Software Development",
"Topic :: Text Editors"
]
dynamic = ["dependencies", "version"]

[project.urls]
"Homepage" = "https://github.com/StartupOS/pygments_tsx"
"Bug Tracker" = "https://github.com/StartupOS/pygments_tsx/issues"
"Source" = "https://github.com/StartupOS/pygments_tsx"

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]

[tool.hatch.version]
path = "VERSION.py"

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[project.entry-points."pygments.lexers"]
jsx="tsx:JsxLexer"
tsx="tsx:TypeScriptXLexer"
12 changes: 3 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,17 @@ dynamic = ["dependencies", "version"]
"Bug Tracker" = "https://github.com/StartupOS/pygments_tsx/issues"
"Source" = "https://github.com/StartupOS/pygments_tsx"

[project.scripts]
verinfast = "verinfast.agent:main"

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]

[tool.setuptools.packages.find]
where = ["src"]

[tool.hatch.version]
path = "VERSION.py"

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[project.entry-points."pygments.lexers"]
jsx="tsx:JsxLexer"
tsx="tsx:TypeScriptXLexer"
# [project.entry-points."pygments.lexers"]
# jsx="tsx:JsxLexer"
# tsx="tsx:TypeScriptXLexer"
34 changes: 34 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from setuptools import setup

# import os
# import datetime


# # Get the version from the git tag, and write to VERSION.
# ref = None
# if "GITHUB_REF" in os.environ:
# ref = os.environ["GITHUB_REF"]

# if ref and ref is not None and ref.startswith("refs/tags/"):
# version = ref.replace("refs/tags/", "")
# else:
# version = datetime.datetime.now().strftime("%Y.%m.%d%H%M%S")

# print(version)

# requirements = []
# with open('requirements.txt') as f:
# requirements = f.read().splitlines()

setup(
# name='pygments_tsx',
# version=version,
package_dir={"": "src"},
packages=['pygments_tsx'],
entry_points="""
[pygments.lexers]
jsx=jsx:JsxLexer
tsx=pygments_tsx.tsx:TypeScriptXLexer
""",
# install_requires=requirements
)
File renamed without changes.
2 changes: 1 addition & 1 deletion src/tsx/tsx.py → src/pygments_tsx/tsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def patch_pygments():
LEXERS['TypeScriptXLexer'] = (
'',
'TypeScriptXLexer',
('typescriptx', 'tsx'),
('typescriptx', 'pygments_tsx'),
('*.tsx',),
('application/x-typescript', 'text/x-typescript')
)
Expand Down
13 changes: 10 additions & 3 deletions test/tsx_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os

import pygments
from pygments import lexers
from pygments.token import _TokenType
from tsx.tsx import TypeScriptXLexer, patch_pygments
from pygments_tsx.tsx import TypeScriptXLexer, patch_pygments

parent = os.path.dirname(__file__)
file_path = os.path.join(parent, 'Blank.tsx')


def test_lexer_on_Blank():
tsx_lexer = TypeScriptXLexer()
parent = os.path.dirname(__file__)
file_path = os.path.join(parent, 'Blank.tsx')
with open(file_path) as f:
txt = f.read()
tokens = pygments.lex(txt, lexer=tsx_lexer)
Expand All @@ -22,4 +24,9 @@ def test_lexer_on_Blank():

def test_patch_pygments():
patch_pygments()
lexers.get_lexer_for_filename(file_path)
assert True


def test_pygmemts():
assert True
Loading