File tree Expand file tree Collapse file tree 4 files changed +112
-86
lines changed
Expand file tree Collapse file tree 4 files changed +112
-86
lines changed Original file line number Diff line number Diff line change @@ -646,6 +646,11 @@ def markdown(text):
646646 return xd .get_default_block ().render_fn (content = text )
647647
648648
649+ def markdown_codeblock (value : str , ** props : object ) -> rx .Component :
650+ """Render a code block using the Shiki-based code block component."""
651+ return rx ._x .code_block (value , ** props )
652+
653+
649654def markdown_with_shiki (* args , ** kwargs ):
650655 """
651656 Wrapper for the markdown component with a customized component map.
@@ -657,8 +662,6 @@ def markdown_with_shiki(*args, **kwargs):
657662 """
658663 return rx .markdown (
659664 * args ,
660- component_map = {
661- "codeblock" : lambda value , ** props : rx ._x .code_block (value , ** props )
662- },
665+ component_map = {"codeblock" : markdown_codeblock },
663666 ** kwargs ,
664667 )
Original file line number Diff line number Diff line change 11"""Components for rendering code demos in the documentation."""
22
3- import reflex as rx
43import textwrap
54from typing import Any
5+
6+ import reflex as rx
7+ import ruff_api
8+
69from .code import code_block , code_block_dark
7- import black
810
911
1012def docdemobox (* children , ** props ) -> rx .Component :
@@ -42,14 +44,12 @@ def doccode(
4244 """
4345 # For Python snippets, lint the code with black.
4446 if language == "python" :
45- code = black .format_str (
46- textwrap .dedent (code ), mode = black .FileMode (line_length = 60 )
47- ).strip ()
47+ code = ruff_api .format_string (path = "" , source = textwrap .dedent (code )).strip ()
4848
4949 # If needed, only display a subset of the lines.
5050 if lines is not None :
5151 code = textwrap .dedent (
52- "\n " .join (code .strip ().split ( " \n " )[lines [0 ] : lines [1 ]])
52+ "\n " .join (code .strip ().splitlines ( )[lines [0 ] : lines [1 ]])
5353 ).strip ()
5454
5555 # Create the code snippet.
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ readme = "README.md"
99requires-python = " >=3.11"
1010dependencies = [
1111 " email-validator==2.2.0" ,
12- " black>=25.0" ,
1312 " pandas>=1.5.3" ,
1413 " psycopg[binary]==3.2.9" ,
1514 " plotly-express==0.4.1" ,
@@ -28,7 +27,8 @@ dependencies = [
2827 " typesense>=1.1.1" ,
2928 " fastapi" ,
3029 " reflex-hosting-cli>=0.1.56" ,
31- " python-frontmatter>=1.1.0"
30+ " python-frontmatter>=1.1.0" ,
31+ " ruff-api>=0.1.0" ,
3232]
3333
3434[dependency-groups ]
You can’t perform that action at this time.
0 commit comments