1
0
Эх сурвалжийг харах

moved markdown code highlight styling into main lib

Rodja Trappe 4 жил өмнө
parent
commit
599041d7f7

+ 0 - 6
api_reference.py

@@ -7,12 +7,6 @@ import inspect
 from executing import Source
 import sys
 
-from pygments import highlight
-from pygments.lexers import PythonLexer
-from pygments.formatters import HtmlFormatter
-
-wp.css = HtmlFormatter().get_style_defs('.codehilite')
-
 @contextmanager
 def example():
     callFrame = inspect.currentframe().f_back.f_back

+ 4 - 0
nicegui/nicegui.py

@@ -4,6 +4,9 @@ import uvicorn
 import sys
 import inspect
 import webbrowser
+from pygments import highlight
+from pygments.lexers import PythonLexer
+from pygments.formatters import HtmlFormatter
 from .ui import Ui
 from .timer import Timer
 from .elements.element import Element
@@ -17,6 +20,7 @@ if not inspect.stack()[-2].filename.endswith('spawn.py'):
 
 wp = jp.QuasarPage(delete_flag=False, title='NiceGUI', favicon='favicon.png')
 wp.head_html = '<script>confirm = () => true;</script>'  # avoid confirmation dialog for reload
+wp.css = HtmlFormatter().get_style_defs('.codehilite')
 
 main = jp.Div(a=wp, classes='q-ma-md column items-start', style='row-gap: 1em')
 main.add_page(wp)

+ 2 - 2
poetry.lock

@@ -271,7 +271,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
 name = "pygments"
 version = "2.9.0"
 description = "Pygments is a syntax highlighting package written in Python."
-category = "dev"
+category = "main"
 optional = false
 python-versions = ">=3.5"
 
@@ -378,7 +378,7 @@ python-versions = ">=3.6.1"
 [metadata]
 lock-version = "1.1"
 python-versions = "^3.7"
-content-hash = "cc5ef26fa759c048c4f3afb686a1ae92096a1889b105e232c3b6777ef4b7cbef"
+content-hash = "52606d24d4be25e5ce4d00e95e26e92de12cca682ab0ee5c68aec8bdaf27ce0d"
 
 [metadata.files]
 addict = [

+ 1 - 1
pyproject.toml

@@ -14,12 +14,12 @@ justpy = "0.1.5"
 matplotlib = "^3.4.1"
 typing-extensions = "^3.10.0"
 markdown2 = "^2.4.0"
+Pygments = "^2.9.0"
 
 [tool.poetry.dev-dependencies]
 icecream = "^2.1.0"
 autopep8 = "^1.5.7"
 debugpy = "^1.3.0"
-Pygments = "^2.9.0"
 
 [build-system]
 requires = ["poetry-core>=1.0.0"]