instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
demo without showing the code."""
starting_indicator = "```python demo-only"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
|
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
| parts = code.rpartition("def") |
g_indicator = "```python demo-only"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
|
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
| data, code = parts[0], parts[1] + parts[2] |
"```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
|
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
b | comp = docgraphing(code, comp=comp, data=data) |
) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
|
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__x | elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
s(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
|
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__x | elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
|
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if | comp = eval(code, env, env) |
c", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
|
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__x | comp = eval(code, env, env) |
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
|
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
| class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
) |
de, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
|
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + p | starting_indicator = "```python demo" |
exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
|
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp | ending_indicator = "```" |
omp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
|
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, | include_indicators = True |
ing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
|
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
| def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
) |
, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
|
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif " | lines = self.get_lines(env) |
not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
|
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval( | code = "\n".join(lines[1:-1]) |
env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
|
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bott | args = lines[0].removeprefix(self.starting_indicator).split() |
he final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
|
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
| exec_mode = env.get("__exec", False) |
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
|
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = | for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None |
arts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
|
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in | if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break |
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
|
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = | comp_id = arg.rsplit("id=")[-1] |
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
|
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = | comp_id = None |
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
|
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
| if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
nv)
return rx.box(comp, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
|
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
| if not exec_mode:
comp = env[list(env.keys())[-1]]() |
, margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
|
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
| comp = env[list(env.keys())[-1]]() |
else:
comp = eval(code, env, env)
# Return only the component without any code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
|
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
| elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
ny code display
return rx.box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
|
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = sel | if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp |
box(comp, margin_bottom="1em", id=comp_id)
class DemoBlock(flexdown.blocks.Block):
"""A block that displays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
|
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark" | comp = env[list(env.keys())[-1]]() |
ays a component along with its code."""
starting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
|
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting | parts = code.rpartition("def") |
arting_indicator = "```python demo"
ending_indicator = "```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
|
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
| data, code = parts[0], parts[1] + parts[2] |
"```"
include_indicators = True
theme: str = None
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
|
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Co | comp = docgraphing(code, comp=comp, data=data) |
) -> rx.Component:
lines = self.get_lines(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
|
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
| elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
s(env)
code = "\n".join(lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
|
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
| elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env) |
lines[1:-1])
args = lines[0].removeprefix(self.starting_indicator).split()
exec_mode = env.get("__exec", False)
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
|
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
| comp = eval(code, env, env) |
comp = ""
for arg in args:
if arg.startswith("id="):
comp_id = arg.rsplit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
|
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
| comp = eval(code, env, env) |
plit("id=")[-1]
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
|
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accord | demobox_props = {} |
break
else:
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
|
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
| for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value |
comp_id = None
if "exec" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
|
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx. | prop, equals, value = arg.partition("=") |
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
|
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
| if equals:
demobox_props[prop] = value |
code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
|
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
| demobox_props[prop] = value |
if not exec_mode:
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
|
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_wit | if "toggle" in args:
demobox_props["toggle"] = True |
comp = env[list(env.keys())[-1]]()
elif "graphing" in args:
env["__xd"].exec(code, env, self.filename)
if not exec_mode:
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
|
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_wit | demobox_props["toggle"] = True |
comp = env[list(env.keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
|
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(co | class DemoBlockDark(DemoBlock):
theme = "dark" |
keys())[-1]]()
# Get all the code before the final "def".
parts = code.rpartition("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
|
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(co | theme = "dark" |
n("def")
data, code = parts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
|
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else ma | starting_indicator = "```md video" |
arts[0], parts[1] + parts[2]
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
|
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Desc | ending_indicator = "```" |
comp = docgraphing(code, comp=comp, data=data)
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
|
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
| include_indicators = True |
return comp
elif exec_mode:
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
|
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
| lines = self.get_lines(env) |
return comp
elif "box" in args:
comp = eval(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
|
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
| args = lines[0].removeprefix(self.starting_indicator).split() |
val(code, env, env)
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
|
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
align_items="center",
| if len(args) == 0:
args = ["info"] |
return rx.box(docdemobox(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
|
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
align_items="center",
| args = ["info"] |
x(comp), margin_bottom="1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
|
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
align_items="center",
j | url = args[0] |
"1em", id=comp_id)
else:
comp = eval(code, env, env)
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
|
color = "blue"
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
align_items="center",
justify_content="left",
text_align="left",
| title = lines[1].strip("#").strip() if lines[1].startswith("#") else "" |
# Sweep up additional CSS-like props to apply to the demobox itself
demobox_props = {}
for arg in args:
prop, equals, value = arg.partition("=")
if equals:
demobox_props[prop] = value
if "toggle" in args:
demobox_props["toggle"] = True
return docdemo(
code, comp=comp, demobox_props=demobox_props, theme=self.theme, id=comp_id
)
class DemoBlockDark(DemoBlock):
theme = "dark"
class VideoBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a video."""
starting_indicator = "```md video"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
args = lines[0].removeprefix(self.starting_indicator).split()
if len(args) == 0:
args = ["info"]
url = args[0]
title = lines[1].strip("#").strip() if lines[1].startswith("#") else ""
|
return rx.box(
rx.accordion.root(
rx.accordion.item(
rx.accordion.header(
rx.accordion.trigger(
rx.hstack(
(
markdown_with_shiki(
title,
margin_y="0px",
style=get_code_style(color),
)
if title
else markdown_with_shiki("Video Description")
),
rx.spacer(),
rx.accordion.icon(color=f"{rx.color(color, 11)}"),
align_items="center",
justify_content="left",
text_align="left",
| color = "blue" |
width="100%",
height="500px",
border_radius="10px",
overflow="hidden",
),
margin_top="16px",
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
|
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.a | class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
) |
border_radius="10px",
overflow="hidden",
),
margin_top="16px",
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
|
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 | starting_indicator = "```md quote" |
overflow="hidden",
),
margin_top="16px",
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
|
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
| ending_indicator = "```" |
hidden",
),
margin_top="16px",
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
|
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.block | include_indicators = True |
),
margin_top="16px",
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
|
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.a | def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
) |
padding="0px",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
|
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicat | lines = self.get_lines(env) |
x",
),
border_radius="0px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
|
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
endin | quote_content = [] |
px",
border="none",
background_color="transparent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
|
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
| for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line) |
parent",
padding=["16px", "24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
|
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
| if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line) |
24px"],
),
background="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
|
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1 | name = line.split(":", 1)[1].strip() |
ound="transparent !important",
box_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
|
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
| elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line) |
x_shadow="none !important",
collapsible=True,
width="100%",
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
|
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
| role = line.split(":", 1)[1].strip() |
border_radius="0px",
),
border=f"1px solid {rx.color(color, 4)}",
border_radius="12px",
background_color=f"{rx.color(color, 3)} !important",
width="100%",
margin_bottom="16px",
margin_top="16px",
overflow="hidden",
)
class QuoteBlock(flexdown.blocks.MarkdownBlock):
"""A block that displays a quote."""
starting_indicator = "```md quote"
ending_indicator = "```"
include_indicators = True
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
|
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.ap | quote_text = "\n".join(quote_content).strip() |
f.get_lines(env)
quote_content = []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
|
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_secti | starting_indicator = "---md tabs" |
= []
name = ""
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
|
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\ | ending_indicator = "---" |
role = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
|
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
| def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
) |
Skip the first and last lines (indicators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
|
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = [ | lines = self.get_lines(env) |
ators)
if line.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
|
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
| tab_sections = [] |
.startswith("- name:"):
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
|
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) | current_section = [] |
name = line.split(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
|
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections) | current_title = "" |
(":", 1)[1].strip()
elif line.startswith("- role:"):
role = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
|
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print( | for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line) |
le = line.split(":", 1)[1].strip()
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
|
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
tit | stripped_line = line.strip() |
else:
quote_content.append(line)
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
|
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print( | if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line) |
quote_text = "\n".join(quote_content).strip()
return rx.box(
rx.text(f'"{quote_text}"', class_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
|
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Rend | if current_title:
tab_sections.append((current_title, "\n".join(current_section))) |
ass_name="text-slate-11 font-base italic"),
rx.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
|
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
| current_title = stripped_line[6:].strip() |
.box(
rx.text(name, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
|
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks | current_section = [] |
e, class_name="text-slate-11 font-base"),
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
|
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print( | elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line) |
rx.text(role, class_name="text-slate-10 font-base"),
class_name="flex flex-col gap-0.5",
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
|
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env | if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = [] |
),
class_name="flex flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
|
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
| current_title = "" |
flex-col gap-4 border-l-[3px] border-slate-4 pl-6 mt-2 mb-6",
)
class TabsBlock(flexdown.blocks.Block):
"""A block that displays content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
|
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env | current_section = [] |
content in tabs."""
starting_indicator = "---md tabs"
ending_indicator = "---"
def render(self, env) -> rx.Component:
lines = self.get_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
|
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
| if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section))) |
t_lines(env)
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
|
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.appen | triggers = [] |
tab_sections = []
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
|
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.f | contents = [] |
current_section = []
current_title = ""
for line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
|
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = fle | for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value)) |
line in lines[1:-1]: # Skip the first and last lines (indicators)
stripped_line = line.strip()
if stripped_line.startswith("--tab "):
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
|
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*tr | value = f"tab{i + 1}" |
= stripped_line[6:].strip()
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
|
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_com | tab_content = [] |
current_section = []
elif stripped_line == "--":
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
|
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
| for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise |
if current_title:
tab_sections.append((current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
|
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeb | if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo |
(current_title, "\n".join(current_section)))
current_title = ""
current_section = []
else:
current_section.append(line)
# Add the last section if there's content
if current_title and current_section:
tab_sections.append((current_title, "\n".join(current_section)))
# Create tab components
triggers = []
contents = []
for i, (title, content) in enumerate(tab_sections):
value = f"tab{i + 1}"
triggers.append(
rx.tabs.trigger(
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
|
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeb | block.render_fn = env["__xd"].flexdown_memo |
title,
value=value,
class_name="tab-style font-base font-semibold text-[1.25rem]",
)
)
# Render the tab content
tab_content = []
for block in env["__xd"].get_blocks(content, self.filename):
if isinstance(block, flexdown.blocks.MarkdownBlock):
block.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
|
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_s | component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
} |
ock.render_fn = env["__xd"].flexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
|
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"" | comp2 = component_map.copy() |
lexdown_memo
try:
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
|
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a cus | comp2["codeblock"] = code_block_markdown_dark |
tab_content.append(block.render(env=env))
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
|
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based | comp2["ul"] = lambda items: unordered_list_comp(items=items) |
except Exception:
print(
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
|
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based code block (rx._x.code_block)
instead of the default Co | comp2["ol"] = lambda items: ordered_list_comp(items=items) |
f"Error while rendering {type(block)} on line {block.start_line_number}. "
f"\n{block.get_content(env)}"
)
raise
contents.append(rx.tabs.content(rx.fragment(*tab_content), value=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
|
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based code block (rx._x.code_block)
instead of the default CodeBlock component for code blocks.
Note: This wrapper should be removed once the default codeblock
in rx.markdown component map is updated to the Shiki-based code block.
"""
return rx.markdown(
*args,
component_map={ | xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
) |
e=value))
return rx.tabs.root(
rx.tabs.list(*triggers, class_name="mt-4"), *contents, default_value="tab1"
)
component_map = {
"h1": lambda text: h1_comp_xd(text=text),
"h2": lambda text: h2_comp_xd(text=text),
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
|
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based code block (rx._x.code_block)
instead of the default CodeBlock component for code blocks.
Note: This wrapper should be removed once the default codeblock
in rx.markdown component map is updated to the Shiki-based code block.
"""
return rx.markdown(
*args,
component_map={"codeblock": markdown_codeblock},
**kwargs,
)
| xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
) |
,
"h3": lambda text: h3_comp_xd(text=text),
"h4": lambda text: h4_comp_xd(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
|
def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props)
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based code block (rx._x.code_block)
instead of the default CodeBlock component for code blocks.
Note: This wrapper should be removed once the default codeblock
in rx.markdown component map is updated to the Shiki-based code block.
"""
return rx.markdown(
*args,
component_map={"codeblock": markdown_codeblock},
**kwargs,
)
| def markdown(text):
return xd.get_default_block().render_fn(content=text) |
d(text=text),
"p": lambda text: text_comp(text=text),
"li": lambda text: list_comp(text=text),
"a": doclink2,
"code": lambda text: code_comp(text=text),
"codeblock": code_block_markdown,
}
comp2 = component_map.copy()
comp2["codeblock"] = code_block_markdown_dark
comp2["ul"] = lambda items: unordered_list_comp(items=items)
comp2["ol"] = lambda items: ordered_list_comp(items=items)
xd = flexdown.Flexdown(
block_types=[
DemoOnly,
DemoBlock,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=component_map,
)
xd.clear_modules()
xd2 = flexdown.Flexdown(
block_types=[
DemoBlockDark,
AlertBlock,
DefinitionBlock,
SectionBlock,
VideoBlock,
TabsBlock,
QuoteBlock,
],
component_map=comp2,
)
xd2.clear_modules()
def markdown(text):
return xd.get_default_block().render_fn(content=text)
|
def markdown_with_shiki(*args, **kwargs):
"""Wrapper for the markdown component with a customized component map.
Uses the experimental Shiki-based code block (rx._x.code_block)
instead of the default CodeBlock component for code blocks.
Note: This wrapper should be removed once the default codeblock
in rx.markdown component map is updated to the Shiki-based code block.
"""
return rx.markdown(
*args,
component_map={"codeblock": markdown_codeblock},
**kwargs,
)
| def markdown_codeblock(value: str, **props: object) -> rx.Component:
"""Render a code block using the Shiki-based code block component."""
return rx._x.code_block(value, **props) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.