reflex-components-markdown 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ **/.DS_Store
2
+ **/*.pyc
3
+ assets/external/*
4
+ dist/*
5
+ examples/
6
+ .web
7
+ .states
8
+ .idea
9
+ .vscode
10
+ .coverage
11
+ .coverage.*
12
+ .venv
13
+ venv
14
+ requirements.txt
15
+ .pyi_generator_last_run
16
+ .pyi_generator_diff
17
+ reflex.db
18
+ .codspeed
19
+ .env
20
+ .env.*
21
+ node_modules
22
+ package-lock.json
23
+ *.pyi
24
+ .pre-commit-config.yaml
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: reflex-components-markdown
3
+ Version: 0.9.0
4
+ Summary: Reflex markdown components.
5
+ Author-email: Khaleel Al-Adhami <khaleel@reflex.dev>
6
+ Maintainer-email: Khaleel Al-Adhami <khaleel@reflex.dev>
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: reflex-components-code
9
+ Requires-Dist: reflex-components-core
10
+ Requires-Dist: reflex-components-radix
11
+ Description-Content-Type: text/markdown
12
+
13
+ # reflex-components-markdown
14
+
15
+ Reflex markdown components.
@@ -0,0 +1,3 @@
1
+ # reflex-components-markdown
2
+
3
+ Reflex markdown components.
@@ -0,0 +1,37 @@
1
+ [project]
2
+ name = "reflex-components-markdown"
3
+ dynamic = ["version"]
4
+ description = "Reflex markdown components."
5
+ readme = "README.md"
6
+ authors = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
7
+ maintainers = [{ name = "Khaleel Al-Adhami", email = "khaleel@reflex.dev" }]
8
+ requires-python = ">=3.10"
9
+ dependencies = [
10
+ "reflex-components-code",
11
+ "reflex-components-core",
12
+ "reflex-components-radix",
13
+ ]
14
+
15
+ [tool.hatch.version]
16
+ source = "uv-dynamic-versioning"
17
+
18
+ [tool.uv-dynamic-versioning]
19
+ pattern-prefix = "reflex-components-markdown-"
20
+ fallback-version = "0.0.0dev0"
21
+
22
+ [tool.hatch.build]
23
+ targets.sdist.artifacts = ["*.pyi"]
24
+ targets.wheel.artifacts = ["*.pyi"]
25
+
26
+ [tool.hatch.build.hooks.reflex-pyi]
27
+ dependencies = [
28
+ "ruff",
29
+ "reflex-base",
30
+ "reflex-components-core",
31
+ "reflex-components-lucide",
32
+ "reflex-components-sonner",
33
+ ]
34
+
35
+ [build-system]
36
+ requires = ["hatchling", "uv-dynamic-versioning", "hatch-reflex-pyi"]
37
+ build-backend = "hatchling.build"
@@ -0,0 +1,3 @@
1
+ """Markdown components."""
2
+
3
+ from .markdown import markdown as markdown
@@ -0,0 +1,576 @@
1
+ """Markdown component."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import textwrap
6
+ from collections.abc import Callable, Sequence
7
+ from functools import lru_cache
8
+ from hashlib import md5
9
+ from types import SimpleNamespace
10
+ from typing import Any
11
+
12
+ from reflex_base.components.component import (
13
+ BaseComponent,
14
+ Component,
15
+ ComponentNamespace,
16
+ CustomComponent,
17
+ field,
18
+ )
19
+ from reflex_base.components.tags.tag import Tag
20
+ from reflex_base.utils.imports import ImportDict, ImportTypes, ImportVar
21
+ from reflex_base.vars.base import LiteralVar, Var, VarData
22
+ from reflex_base.vars.number import ternary_operation
23
+ from reflex_base.vars.sequence import LiteralArrayVar
24
+ from reflex_components_core.core.markdown_component_map import MarkdownComponentMap
25
+ from reflex_components_core.el.elements.typography import Div
26
+
27
+ # Special vars used in the component map.
28
+ _CHILDREN = Var(_js_expr="children", _var_type=str)
29
+ _PROPS = Var(_js_expr="props")
30
+ _PROPS_SPREAD = Var(_js_expr="...props")
31
+ _REST = Var(_js_expr="rest")
32
+ _REST_SPREAD = Var(_js_expr="...rest")
33
+ _MOCK_ARG = Var(_js_expr="", _var_type=str)
34
+ _LANGUAGE = Var(_js_expr="_language", _var_type=str)
35
+
36
+
37
+ class Plugin(SimpleNamespace):
38
+ """Create new remark/rehype plugin or access pre-wrapped plugins."""
39
+
40
+ @staticmethod
41
+ def create(
42
+ package: str,
43
+ tag: str,
44
+ additional_imports: dict[str, ImportTypes] | None = None,
45
+ **import_var_kwargs,
46
+ ) -> Var:
47
+ """Create a plugin Var.
48
+
49
+ Args:
50
+ package: The package to import the plugin from.
51
+ tag: The imported identifier.
52
+ additional_imports: Additional imports to include in the VarData, such as CSS.
53
+ **import_var_kwargs: Additional kwargs to pass to the ImportVar.
54
+
55
+ Returns:
56
+ The plugin Var.
57
+ """
58
+ import_var_kwargs.setdefault("is_default", True)
59
+ return Var(
60
+ _js_expr=tag,
61
+ _var_data=VarData(
62
+ imports={
63
+ package: ImportVar(
64
+ tag=tag,
65
+ **import_var_kwargs,
66
+ ),
67
+ **(additional_imports or {}),
68
+ }
69
+ ),
70
+ )
71
+
72
+ __call__ = create
73
+
74
+ math = create("remark-math@6.0.0", "remarkMath")
75
+ gfm = create("remark-gfm@4.0.1", "remarkGfm")
76
+ unwrap_images = create("rehype-unwrap-images@1.0.0", "rehypeUnwrapImages")
77
+ katex = create(
78
+ "rehype-katex@7.0.1",
79
+ "rehypeKatex",
80
+ additional_imports={
81
+ "": "katex/dist/katex.min.css",
82
+ },
83
+ )
84
+ raw = create("rehype-raw@7.0.0", "rehypeRaw")
85
+ _undefined = Var(_js_expr="() => undefined")
86
+
87
+
88
+ def _h1(value: object):
89
+ from reflex_components_radix.themes.typography.heading import Heading
90
+
91
+ return Heading.create(value, as_="h1", size="6", margin_y="0.5em")
92
+
93
+
94
+ def _h2(value: object):
95
+ from reflex_components_radix.themes.typography.heading import Heading
96
+
97
+ return Heading.create(value, as_="h2", size="5", margin_y="0.5em")
98
+
99
+
100
+ def _h3(value: object):
101
+ from reflex_components_radix.themes.typography.heading import Heading
102
+
103
+ return Heading.create(value, as_="h3", size="4", margin_y="0.5em")
104
+
105
+
106
+ def _h4(value: object):
107
+ from reflex_components_radix.themes.typography.heading import Heading
108
+
109
+ return Heading.create(value, as_="h4", size="3", margin_y="0.5em")
110
+
111
+
112
+ def _h5(value: object):
113
+ from reflex_components_radix.themes.typography.heading import Heading
114
+
115
+ return Heading.create(value, as_="h5", size="2", margin_y="0.5em")
116
+
117
+
118
+ def _h6(value: object):
119
+ from reflex_components_radix.themes.typography.heading import Heading
120
+
121
+ return Heading.create(value, as_="h6", size="1", margin_y="0.5em")
122
+
123
+
124
+ def _p(value: object):
125
+ from reflex_components_radix.themes.typography.text import Text
126
+
127
+ return Text.create(value, margin_y="1em")
128
+
129
+
130
+ def _ul(value: object):
131
+ from reflex_components_radix.themes.layout.list import UnorderedList
132
+
133
+ return UnorderedList.create(value, margin_y="1em")
134
+
135
+
136
+ def _ol(value: object):
137
+ from reflex_components_radix.themes.layout.list import OrderedList
138
+
139
+ return OrderedList.create(value, margin_y="1em")
140
+
141
+
142
+ def _li(value: object):
143
+ from reflex_components_radix.themes.layout.list import ListItem
144
+
145
+ return ListItem.create(value, margin_y="0.5em")
146
+
147
+
148
+ def _a(value: object):
149
+ from reflex_components_radix.themes.typography.link import Link
150
+
151
+ return Link.create(value)
152
+
153
+
154
+ def _code(value: object):
155
+ from reflex_components_radix.themes.typography.code import Code
156
+
157
+ return Code.create(value)
158
+
159
+
160
+ def _codeblock(value: object, **props):
161
+ from reflex_components_code.code import CodeBlock
162
+
163
+ return CodeBlock.create(value, margin_y="1em", wrap_long_lines=True, **props)
164
+
165
+
166
+ # Component Mapping
167
+ @lru_cache
168
+ def get_base_component_map() -> dict[str, Callable]:
169
+ """Get the base component map.
170
+
171
+ Returns:
172
+ The base component map.
173
+ """
174
+ return {
175
+ "h1": _h1,
176
+ "h2": _h2,
177
+ "h3": _h3,
178
+ "h4": _h4,
179
+ "h5": _h5,
180
+ "h6": _h6,
181
+ "p": _p,
182
+ "ul": _ul,
183
+ "ol": _ol,
184
+ "li": _li,
185
+ "a": _a,
186
+ "code": _code,
187
+ "pre": _codeblock,
188
+ }
189
+
190
+
191
+ class Markdown(Component):
192
+ """A markdown component."""
193
+
194
+ library = "react-markdown@10.1.0"
195
+
196
+ tag = "ReactMarkdown"
197
+
198
+ is_default = True
199
+
200
+ component_map: dict[str, Any] = field(
201
+ doc="The component map from a tag to a lambda that creates a component.",
202
+ default_factory=dict,
203
+ is_javascript_property=False,
204
+ )
205
+
206
+ component_map_hash: str = field(
207
+ doc="The hash of the component map, generated at create() time.",
208
+ default="",
209
+ is_javascript_property=False,
210
+ )
211
+
212
+ remark_plugins: Var[Sequence[Var | tuple[Var, Var]]] = field(
213
+ doc="Remark plugins to use when rendering the content. Provide (plugin, options) if the plugin requires options."
214
+ )
215
+
216
+ rehype_plugins: Var[Sequence[Var | tuple[Var, Var]]] = field(
217
+ doc="Rehype (HTML processor) plugins to use when rendering the content. Provide (plugin, options) if the plugin requires options."
218
+ )
219
+
220
+ @classmethod
221
+ def create(
222
+ cls,
223
+ *children,
224
+ **props,
225
+ ) -> Component:
226
+ """Create a markdown component.
227
+
228
+ Args:
229
+ *children: The children of the component.
230
+ **props: The properties of the component.
231
+
232
+ Returns:
233
+ The markdown component.
234
+
235
+ Raises:
236
+ ValueError: If the children are not valid.
237
+ """
238
+ if len(children) != 1 or not isinstance(children[0], (str, Var)):
239
+ msg = "Markdown component must have exactly one child containing the markdown source."
240
+ raise ValueError(msg)
241
+
242
+ # Update the base component map with the custom component map.
243
+ component_map = {**get_base_component_map(), **props.pop("component_map", {})}
244
+
245
+ # Get the markdown source.
246
+ src = children[0]
247
+
248
+ # Dedent the source.
249
+ if isinstance(src, str):
250
+ src = textwrap.dedent(src)
251
+
252
+ # Create the component.
253
+ return super().create(
254
+ src,
255
+ component_map=component_map,
256
+ component_map_hash=cls._component_map_hash(component_map),
257
+ **props,
258
+ )
259
+
260
+ def add_imports(self) -> ImportDict | list[ImportDict]:
261
+ """Add imports for the markdown component.
262
+
263
+ Returns:
264
+ The imports for the markdown component.
265
+ """
266
+ return [
267
+ *[
268
+ component(_MOCK_ARG)._get_all_imports()
269
+ for component in self.component_map.values()
270
+ ],
271
+ *(
272
+ [codeblock_var_data.old_school_imports()]
273
+ if (
274
+ codeblock_var_data
275
+ := self._get_codeblock_fn_var()._get_all_var_data()
276
+ )
277
+ is not None
278
+ else []
279
+ ),
280
+ ]
281
+
282
+ def _get_tag_map_fn_var(self, tag: str) -> Var:
283
+ return self._get_map_fn_var_from_children(self.get_component(tag), tag)
284
+
285
+ def format_component_map(self) -> dict[str, Var]:
286
+ """Format the component map for rendering.
287
+
288
+ Returns:
289
+ The formatted component map.
290
+ """
291
+ components = {
292
+ tag: self._get_tag_map_fn_var(tag)
293
+ for tag in self.component_map
294
+ if tag != "pre"
295
+ }
296
+
297
+ # Special handling for code blocks to extract the language.
298
+ components["pre"] = self._get_codeblock_fn_var()
299
+
300
+ return components
301
+
302
+ def _get_codeblock_fn_var(self) -> Var:
303
+ """Get the function variable for codeblock.
304
+
305
+ This function creates a Var that represents a function to handle
306
+ both code blocks in markdown.
307
+
308
+ Returns:
309
+ The Var for pre code.
310
+ """
311
+ # Get any custom code from the code block "pre" component.
312
+ custom_code_list = self._get_map_fn_custom_code_from_children(
313
+ self.get_component("pre")
314
+ )
315
+ var_data = VarData.merge(*[
316
+ code._get_all_var_data()
317
+ for code in custom_code_list
318
+ if isinstance(code, Var)
319
+ ])
320
+ codeblock_custom_code = "\n".join(map(str, custom_code_list))
321
+
322
+ # Format the code to handle code block with language extraction.
323
+ formatted_code = f"""
324
+ const {{node: childNode, className, children: components, {_PROPS_SPREAD._js_expr}}} = {_REST._js_expr}.children.props;
325
+ const {_CHILDREN._js_expr} = String(Array.isArray(components) ? components.join('\\n') : components).replace(/\\n$/, '');
326
+ const match = (className || '').match(/language-(?<lang>.*)/);
327
+ let {_LANGUAGE!s} = match ? match[1] : '';
328
+ {codeblock_custom_code};
329
+ return {self.format_component("pre", language=_LANGUAGE)};
330
+ """.replace("\n", " ")
331
+
332
+ return MarkdownComponentMap.create_map_fn_var(
333
+ fn_body=Var(_js_expr=formatted_code),
334
+ fn_args=["node", _REST_SPREAD._js_expr],
335
+ explicit_return=True,
336
+ var_data=var_data,
337
+ )
338
+
339
+ def get_component(self, tag: str, **props) -> Component:
340
+ """Get the component for a tag and props.
341
+
342
+ Args:
343
+ tag: The tag of the component.
344
+ **props: The props of the component.
345
+
346
+ Returns:
347
+ The component.
348
+
349
+ Raises:
350
+ ValueError: If the tag is invalid.
351
+ """
352
+ # Check the tag is valid.
353
+ if tag not in self.component_map:
354
+ msg = f"No markdown component found for tag: {tag}."
355
+ raise ValueError(msg)
356
+
357
+ # If the children are set as a prop, don't pass them as children.
358
+ children = [_CHILDREN] if props.get("children") is None else []
359
+ # Get the component.
360
+ return self.component_map[tag](*children, **props).set(special_props=[_PROPS])
361
+
362
+ def format_component(self, tag: str, **props) -> str:
363
+ """Format a component for rendering in the component map.
364
+
365
+ Args:
366
+ tag: The tag of the component.
367
+ **props: Extra props to pass to the component function.
368
+
369
+ Returns:
370
+ The formatted component.
371
+ """
372
+ return str(self.get_component(tag, **props)).replace("\n", "")
373
+
374
+ def _get_map_fn_var_from_children(self, component: Component, tag: str) -> Var:
375
+ """Create a function Var for the component map for the specified tag.
376
+
377
+ Args:
378
+ component: The component to check for custom code.
379
+ tag: The tag of the component.
380
+
381
+ Returns:
382
+ The function Var for the component map.
383
+ """
384
+ formatted_component = Var(
385
+ _js_expr=f"({self.format_component(tag)})", _var_type=str
386
+ )
387
+ if isinstance(component, MarkdownComponentMap):
388
+ return component.create_map_fn_var(fn_body=formatted_component)
389
+
390
+ # fallback to the default fn Var creation if the component is not a MarkdownComponentMap.
391
+ return MarkdownComponentMap.create_map_fn_var(fn_body=formatted_component)
392
+
393
+ def _get_map_fn_custom_code_from_children(
394
+ self, component: BaseComponent
395
+ ) -> list[str | Var]:
396
+ """Recursively get markdown custom code from children components.
397
+
398
+ Args:
399
+ component: The component to check for custom code.
400
+
401
+ Returns:
402
+ A list of markdown custom code strings.
403
+ """
404
+ custom_code_list: list[str | Var] = []
405
+ if isinstance(component, MarkdownComponentMap):
406
+ custom_code_list.append(component.get_component_map_custom_code())
407
+
408
+ # If the component is a custom component(rx.memo), obtain the underlining
409
+ # component and get the custom code from the children.
410
+ if isinstance(component, CustomComponent):
411
+ custom_code_list.extend(
412
+ self._get_map_fn_custom_code_from_children(
413
+ component.component_fn(*component.get_prop_vars())
414
+ )
415
+ )
416
+ elif isinstance(component, Component):
417
+ for child in component.children:
418
+ custom_code_list.extend(
419
+ self._get_map_fn_custom_code_from_children(child)
420
+ )
421
+
422
+ return custom_code_list
423
+
424
+ @staticmethod
425
+ def _component_map_hash(component_map: dict) -> str:
426
+ inp = str({
427
+ tag: (
428
+ f"{component.__module__}.{component.__qualname__}"
429
+ if (
430
+ "<" not in component.__name__
431
+ ) # simple way to check against lambdas
432
+ else component(_MOCK_ARG)
433
+ )
434
+ for tag, component in component_map.items()
435
+ }).encode()
436
+ return md5(inp).hexdigest()
437
+
438
+ def _get_component_map_name(self) -> str:
439
+ return f"ComponentMap_{self.component_map_hash}"
440
+
441
+ def _get_custom_code(self) -> str | None:
442
+ hooks = {}
443
+ from reflex_base.compiler.templates import _render_hooks
444
+
445
+ for component_factory in self.component_map.values():
446
+ comp = component_factory(_MOCK_ARG)
447
+ hooks.update(comp._get_all_hooks())
448
+ formatted_hooks = _render_hooks(hooks)
449
+ return f"""
450
+ function {self._get_component_map_name()} () {{
451
+ {formatted_hooks}
452
+ return (
453
+ {LiteralVar.create(self.format_component_map())!s}
454
+ )
455
+ }}
456
+ """
457
+
458
+ def _render(self) -> Tag:
459
+ return (
460
+ super()
461
+ ._render()
462
+ .add_props(
463
+ components=Var(_js_expr=f"{self._get_component_map_name()}()"),
464
+ )
465
+ .remove_props("componentMap", "componentMapHash")
466
+ )
467
+
468
+
469
+ class MarkdownWrapper(Div):
470
+ """A markdown component, with optional div-wrapping when style props are given."""
471
+
472
+ @classmethod
473
+ def create(
474
+ cls,
475
+ *children,
476
+ use_math: bool | Var[bool] = True,
477
+ use_gfm: bool | Var[bool] = True,
478
+ use_unwrap_images: bool | Var[bool] = True,
479
+ use_katex: bool | Var[bool] = True,
480
+ use_raw: bool | Var[bool] = True,
481
+ **props,
482
+ ) -> Component:
483
+ """Create a markdown component.
484
+
485
+ Args:
486
+ *children: The children of the component.
487
+ use_math: Whether to use the remark-math plugin.
488
+ use_gfm: Whether to use the GitHub Flavored Markdown plugin.
489
+ use_unwrap_images: Whether to use the unwrap images plugin.
490
+ use_katex: Whether to use the KaTeX plugin.
491
+ use_raw: Whether to use the raw HTML plugin.
492
+ **props: The properties of the component.
493
+
494
+ Returns:
495
+ The markdown component or div wrapping markdown component.
496
+
497
+ Raises:
498
+ ValueError: If the children are not valid.
499
+ """
500
+ # Assemble the plugin lists.
501
+ builtin_remark_plugins = []
502
+ if isinstance(use_math, Var):
503
+ builtin_remark_plugins.append(
504
+ ternary_operation(
505
+ use_math, markdown.plugin.math, markdown.plugin._undefined
506
+ )
507
+ )
508
+ elif use_math:
509
+ builtin_remark_plugins.append(markdown.plugin.math)
510
+ if isinstance(use_gfm, Var):
511
+ builtin_remark_plugins.append(
512
+ ternary_operation(
513
+ use_gfm, markdown.plugin.gfm, markdown.plugin._undefined
514
+ )
515
+ )
516
+ elif use_gfm:
517
+ builtin_remark_plugins.append(markdown.plugin.gfm)
518
+ remark_plugins = LiteralArrayVar.create(builtin_remark_plugins)
519
+ if (user_remark_plugins := props.pop("remark_plugins", None)) is not None:
520
+ if not isinstance(user_remark_plugins, Var):
521
+ user_remark_plugins = Var.create(user_remark_plugins)
522
+ remark_plugins = remark_plugins + user_remark_plugins.to(list)
523
+
524
+ builtin_rehype_plugins = []
525
+ if isinstance(use_katex, Var):
526
+ builtin_rehype_plugins.append(
527
+ ternary_operation(
528
+ use_katex, markdown.plugin.katex, markdown.plugin._undefined
529
+ )
530
+ )
531
+ elif use_katex:
532
+ builtin_rehype_plugins.append(markdown.plugin.katex)
533
+ if isinstance(use_raw, Var):
534
+ builtin_rehype_plugins.append(
535
+ ternary_operation(
536
+ use_raw, markdown.plugin.raw, markdown.plugin._undefined
537
+ )
538
+ )
539
+ elif use_raw:
540
+ builtin_rehype_plugins.append(markdown.plugin.raw)
541
+ if isinstance(use_unwrap_images, Var):
542
+ builtin_rehype_plugins.append(
543
+ ternary_operation(
544
+ use_unwrap_images,
545
+ markdown.plugin.unwrap_images,
546
+ markdown.plugin._undefined,
547
+ )
548
+ )
549
+ elif use_unwrap_images:
550
+ builtin_rehype_plugins.append(markdown.plugin.unwrap_images)
551
+ rehype_plugins = LiteralArrayVar.create(builtin_rehype_plugins)
552
+ if (user_rehype_plugins := props.pop("rehype_plugins", None)) is not None:
553
+ if not isinstance(user_rehype_plugins, Var):
554
+ user_rehype_plugins = Var.create(user_rehype_plugins)
555
+ rehype_plugins = rehype_plugins + user_rehype_plugins.to(list)
556
+
557
+ return super().create(
558
+ Markdown.create(
559
+ *children,
560
+ component_map=props.pop("component_map", {}),
561
+ remark_plugins=remark_plugins.to(list[Var | tuple[Var, Var]]),
562
+ rehype_plugins=rehype_plugins.to(list[Var | tuple[Var, Var]]),
563
+ ),
564
+ **props,
565
+ )
566
+
567
+
568
+ class MarkdownNamespace(ComponentNamespace):
569
+ """A namespace for markdown components."""
570
+
571
+ __call__ = staticmethod(MarkdownWrapper.create)
572
+ root = staticmethod(Markdown.create)
573
+ plugin = Plugin()
574
+
575
+
576
+ markdown = MarkdownNamespace()
@@ -0,0 +1,703 @@
1
+ """Stub file for reflex_components_markdown/markdown.py"""
2
+
3
+ # ------------------- DO NOT EDIT ----------------------
4
+ # This file was generated by `reflex/utils/pyi_generator.py`!
5
+ # ------------------------------------------------------
6
+ from collections.abc import Callable, Mapping, Sequence
7
+ from functools import lru_cache
8
+ from types import SimpleNamespace
9
+ from typing import Any, Literal
10
+
11
+ from reflex_base.components.component import Component, ComponentNamespace
12
+ from reflex_base.event import EventType, PointerEventInfo
13
+ from reflex_base.utils.imports import ImportDict, ImportTypes, ImportVar
14
+ from reflex_base.vars.base import Var
15
+ from reflex_components_core.core.breakpoints import Breakpoints
16
+ from reflex_components_core.el.elements.typography import Div
17
+
18
+ _CHILDREN = Var(_js_expr="children", _var_type=str)
19
+ _PROPS = Var(_js_expr="props")
20
+ _PROPS_SPREAD = Var(_js_expr="...props")
21
+ _REST = Var(_js_expr="rest")
22
+ _REST_SPREAD = Var(_js_expr="...rest")
23
+ _MOCK_ARG = Var(_js_expr="", _var_type=str)
24
+ _LANGUAGE = Var(_js_expr="_language", _var_type=str)
25
+
26
+ class Plugin(SimpleNamespace):
27
+ @staticmethod
28
+ def create(
29
+ package: str,
30
+ tag: str,
31
+ additional_imports: dict[str, ImportTypes] | None = None,
32
+ **import_var_kwargs,
33
+ ) -> Var: ...
34
+ math = create("remark-math@6.0.0", "remarkMath")
35
+ gfm = create("remark-gfm@4.0.1", "remarkGfm")
36
+ unwrap_images = create("rehype-unwrap-images@1.0.0", "rehypeUnwrapImages")
37
+ katex = create(
38
+ "rehype-katex@7.0.1",
39
+ "rehypeKatex",
40
+ additional_imports={"": "katex/dist/katex.min.css"},
41
+ )
42
+ raw = create("rehype-raw@7.0.0", "rehypeRaw")
43
+ _undefined = Var(_js_expr="() => undefined")
44
+
45
+ @staticmethod
46
+ def __call__(
47
+ package: str,
48
+ tag: str,
49
+ additional_imports: dict[
50
+ str, ImportVar | list[ImportVar | str] | list[ImportVar] | str
51
+ ]
52
+ | None = None,
53
+ **props,
54
+ ) -> Var:
55
+ """Create a plugin Var.
56
+
57
+ Args:
58
+ package: The package to import the plugin from.
59
+ tag: The imported identifier.
60
+ additional_imports: Additional imports to include in the VarData, such as CSS.
61
+ **import_var_kwargs: Additional kwargs to pass to the ImportVar.
62
+
63
+ Returns:
64
+ The plugin Var.
65
+ """
66
+
67
+ @lru_cache
68
+ def get_base_component_map() -> dict[str, Callable]: ...
69
+
70
+ class Markdown(Component):
71
+ @classmethod
72
+ def create(
73
+ cls,
74
+ *children,
75
+ component_map: dict[str, Any] | None = None,
76
+ component_map_hash: str | None = None,
77
+ remark_plugins: Sequence[Var | tuple[Var, Var]]
78
+ | Var[Sequence[Var | tuple[Var, Var]]]
79
+ | None = None,
80
+ rehype_plugins: Sequence[Var | tuple[Var, Var]]
81
+ | Var[Sequence[Var | tuple[Var, Var]]]
82
+ | None = None,
83
+ style: Sequence[Mapping[str, Any]]
84
+ | Mapping[str, Any]
85
+ | Var[Mapping[str, Any]]
86
+ | Breakpoints
87
+ | None = None,
88
+ key: Any | None = None,
89
+ id: Any | None = None,
90
+ ref: Var | None = None,
91
+ class_name: Any | None = None,
92
+ custom_attrs: dict[str, Any | Var] | None = None,
93
+ on_blur: EventType[()] | None = None,
94
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
95
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
96
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
97
+ on_focus: EventType[()] | None = None,
98
+ on_mount: EventType[()] | None = None,
99
+ on_mouse_down: EventType[()] | None = None,
100
+ on_mouse_enter: EventType[()] | None = None,
101
+ on_mouse_leave: EventType[()] | None = None,
102
+ on_mouse_move: EventType[()] | None = None,
103
+ on_mouse_out: EventType[()] | None = None,
104
+ on_mouse_over: EventType[()] | None = None,
105
+ on_mouse_up: EventType[()] | None = None,
106
+ on_scroll: EventType[()] | None = None,
107
+ on_scroll_end: EventType[()] | None = None,
108
+ on_unmount: EventType[()] | None = None,
109
+ **props,
110
+ ) -> Markdown:
111
+ """Create a markdown component.
112
+
113
+ Args:
114
+ *children: The children of the component.
115
+ component_map: The component map from a tag to a lambda that creates a component.
116
+ component_map_hash: The hash of the component map, generated at create() time.
117
+ remark_plugins: Remark plugins to use when rendering the content. Provide (plugin, options) if the plugin requires options.
118
+ rehype_plugins: Rehype (HTML processor) plugins to use when rendering the content. Provide (plugin, options) if the plugin requires options.
119
+ style: The style of the component.
120
+ key: A unique key for the component.
121
+ id: The id for the component.
122
+ ref: The Var to pass as the ref to the component.
123
+ class_name: The class name for the component.
124
+ custom_attrs: Attributes passed directly to the component.
125
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
126
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
127
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
128
+ on_context_menu: Fired when the user right-clicks on an element.
129
+ on_double_click: Fired when the user double-clicks on an element.
130
+ on_mouse_down: Fired when the user presses a mouse button on an element.
131
+ on_mouse_enter: Fired when the mouse pointer enters the element.
132
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
133
+ on_mouse_move: Fired when the mouse pointer moves over the element.
134
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
135
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
136
+ on_mouse_up: Fired when the user releases a mouse button on an element.
137
+ on_scroll: Fired when the user scrolls the element.
138
+ on_scroll_end: Fired when scrolling ends on the element.
139
+ on_mount: Fired when the component is mounted to the page.
140
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
141
+ **props: The properties of the component.
142
+
143
+ Returns:
144
+ The markdown component.
145
+
146
+ Raises:
147
+ ValueError: If the children are not valid.
148
+ """
149
+
150
+ def add_imports(self) -> ImportDict | list[ImportDict]: ...
151
+ def format_component_map(self) -> dict[str, Var]: ...
152
+ def get_component(self, tag: str, **props) -> Component: ...
153
+ def format_component(self, tag: str, **props) -> str: ...
154
+
155
+ class MarkdownWrapper(Div):
156
+ @classmethod
157
+ def create(
158
+ cls,
159
+ *children,
160
+ use_math: bool | Var[bool] | bool = True,
161
+ use_gfm: bool | Var[bool] | bool = True,
162
+ use_unwrap_images: bool | Var[bool] | bool = True,
163
+ use_katex: bool | Var[bool] | bool = True,
164
+ use_raw: bool | Var[bool] | bool = True,
165
+ access_key: Var[str] | str | None = None,
166
+ auto_capitalize: Literal[
167
+ "characters", "none", "off", "on", "sentences", "words"
168
+ ]
169
+ | Var[Literal["characters", "none", "off", "on", "sentences", "words"]]
170
+ | None = None,
171
+ content_editable: Literal["inherit", "plaintext-only"]
172
+ | Var[Literal["inherit", "plaintext-only"] | bool]
173
+ | bool
174
+ | None = None,
175
+ context_menu: Var[str] | str | None = None,
176
+ dir: Var[str] | str | None = None,
177
+ draggable: Var[bool] | bool | None = None,
178
+ enter_key_hint: Literal[
179
+ "done", "enter", "go", "next", "previous", "search", "send"
180
+ ]
181
+ | Var[Literal["done", "enter", "go", "next", "previous", "search", "send"]]
182
+ | None = None,
183
+ hidden: Var[bool] | bool | None = None,
184
+ input_mode: Literal[
185
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
186
+ ]
187
+ | Var[
188
+ Literal[
189
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
190
+ ]
191
+ ]
192
+ | None = None,
193
+ item_prop: Var[str] | str | None = None,
194
+ lang: Var[str] | str | None = None,
195
+ role: Literal[
196
+ "alert",
197
+ "alertdialog",
198
+ "application",
199
+ "article",
200
+ "banner",
201
+ "button",
202
+ "cell",
203
+ "checkbox",
204
+ "columnheader",
205
+ "combobox",
206
+ "complementary",
207
+ "contentinfo",
208
+ "definition",
209
+ "dialog",
210
+ "directory",
211
+ "document",
212
+ "feed",
213
+ "figure",
214
+ "form",
215
+ "grid",
216
+ "gridcell",
217
+ "group",
218
+ "heading",
219
+ "img",
220
+ "link",
221
+ "list",
222
+ "listbox",
223
+ "listitem",
224
+ "log",
225
+ "main",
226
+ "marquee",
227
+ "math",
228
+ "menu",
229
+ "menubar",
230
+ "menuitem",
231
+ "menuitemcheckbox",
232
+ "menuitemradio",
233
+ "navigation",
234
+ "none",
235
+ "note",
236
+ "option",
237
+ "presentation",
238
+ "progressbar",
239
+ "radio",
240
+ "radiogroup",
241
+ "region",
242
+ "row",
243
+ "rowgroup",
244
+ "rowheader",
245
+ "scrollbar",
246
+ "search",
247
+ "searchbox",
248
+ "separator",
249
+ "slider",
250
+ "spinbutton",
251
+ "status",
252
+ "switch",
253
+ "tab",
254
+ "table",
255
+ "tablist",
256
+ "tabpanel",
257
+ "term",
258
+ "textbox",
259
+ "timer",
260
+ "toolbar",
261
+ "tooltip",
262
+ "tree",
263
+ "treegrid",
264
+ "treeitem",
265
+ ]
266
+ | Var[
267
+ Literal[
268
+ "alert",
269
+ "alertdialog",
270
+ "application",
271
+ "article",
272
+ "banner",
273
+ "button",
274
+ "cell",
275
+ "checkbox",
276
+ "columnheader",
277
+ "combobox",
278
+ "complementary",
279
+ "contentinfo",
280
+ "definition",
281
+ "dialog",
282
+ "directory",
283
+ "document",
284
+ "feed",
285
+ "figure",
286
+ "form",
287
+ "grid",
288
+ "gridcell",
289
+ "group",
290
+ "heading",
291
+ "img",
292
+ "link",
293
+ "list",
294
+ "listbox",
295
+ "listitem",
296
+ "log",
297
+ "main",
298
+ "marquee",
299
+ "math",
300
+ "menu",
301
+ "menubar",
302
+ "menuitem",
303
+ "menuitemcheckbox",
304
+ "menuitemradio",
305
+ "navigation",
306
+ "none",
307
+ "note",
308
+ "option",
309
+ "presentation",
310
+ "progressbar",
311
+ "radio",
312
+ "radiogroup",
313
+ "region",
314
+ "row",
315
+ "rowgroup",
316
+ "rowheader",
317
+ "scrollbar",
318
+ "search",
319
+ "searchbox",
320
+ "separator",
321
+ "slider",
322
+ "spinbutton",
323
+ "status",
324
+ "switch",
325
+ "tab",
326
+ "table",
327
+ "tablist",
328
+ "tabpanel",
329
+ "term",
330
+ "textbox",
331
+ "timer",
332
+ "toolbar",
333
+ "tooltip",
334
+ "tree",
335
+ "treegrid",
336
+ "treeitem",
337
+ ]
338
+ ]
339
+ | None = None,
340
+ slot: Var[str] | str | None = None,
341
+ spell_check: Var[bool] | bool | None = None,
342
+ tab_index: Var[int] | int | None = None,
343
+ title: Var[str] | str | None = None,
344
+ style: Sequence[Mapping[str, Any]]
345
+ | Mapping[str, Any]
346
+ | Var[Mapping[str, Any]]
347
+ | Breakpoints
348
+ | None = None,
349
+ key: Any | None = None,
350
+ id: Any | None = None,
351
+ ref: Var | None = None,
352
+ class_name: Any | None = None,
353
+ custom_attrs: dict[str, Any | Var] | None = None,
354
+ on_blur: EventType[()] | None = None,
355
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
356
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
357
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
358
+ on_focus: EventType[()] | None = None,
359
+ on_mount: EventType[()] | None = None,
360
+ on_mouse_down: EventType[()] | None = None,
361
+ on_mouse_enter: EventType[()] | None = None,
362
+ on_mouse_leave: EventType[()] | None = None,
363
+ on_mouse_move: EventType[()] | None = None,
364
+ on_mouse_out: EventType[()] | None = None,
365
+ on_mouse_over: EventType[()] | None = None,
366
+ on_mouse_up: EventType[()] | None = None,
367
+ on_scroll: EventType[()] | None = None,
368
+ on_scroll_end: EventType[()] | None = None,
369
+ on_unmount: EventType[()] | None = None,
370
+ **props,
371
+ ) -> MarkdownWrapper:
372
+ """Create a markdown component.
373
+
374
+ Args:
375
+ *children: The children of the component.
376
+ use_math: Whether to use the remark-math plugin.
377
+ use_gfm: Whether to use the GitHub Flavored Markdown plugin.
378
+ use_unwrap_images: Whether to use the unwrap images plugin.
379
+ use_katex: Whether to use the KaTeX plugin.
380
+ use_raw: Whether to use the raw HTML plugin.
381
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
382
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
383
+ content_editable: Indicates whether the element's content is editable.
384
+ context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
385
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
386
+ draggable: Defines whether the element can be dragged.
387
+ enter_key_hint: Hints what media types the media element is able to play.
388
+ hidden: Defines whether the element is hidden.
389
+ input_mode: Defines the type of the element.
390
+ item_prop: Defines the name of the element for metadata purposes.
391
+ lang: Defines the language used in the element.
392
+ role: Defines the role of the element.
393
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
394
+ spell_check: Defines whether the element may be checked for spelling errors.
395
+ tab_index: Defines the position of the current element in the tabbing order.
396
+ title: Defines a tooltip for the element.
397
+ style: The style of the component.
398
+ key: A unique key for the component.
399
+ id: The id for the component.
400
+ ref: The Var to pass as the ref to the component.
401
+ class_name: The class name for the component.
402
+ custom_attrs: Attributes passed directly to the component.
403
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
404
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
405
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
406
+ on_context_menu: Fired when the user right-clicks on an element.
407
+ on_double_click: Fired when the user double-clicks on an element.
408
+ on_mouse_down: Fired when the user presses a mouse button on an element.
409
+ on_mouse_enter: Fired when the mouse pointer enters the element.
410
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
411
+ on_mouse_move: Fired when the mouse pointer moves over the element.
412
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
413
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
414
+ on_mouse_up: Fired when the user releases a mouse button on an element.
415
+ on_scroll: Fired when the user scrolls the element.
416
+ on_scroll_end: Fired when scrolling ends on the element.
417
+ on_mount: Fired when the component is mounted to the page.
418
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
419
+ **props: The properties of the component.
420
+
421
+ Returns:
422
+ The markdown component or div wrapping markdown component.
423
+
424
+ Raises:
425
+ ValueError: If the children are not valid.
426
+ """
427
+
428
+ class MarkdownNamespace(ComponentNamespace):
429
+ root = staticmethod(Markdown.create)
430
+ plugin = Plugin()
431
+
432
+ @staticmethod
433
+ def __call__(
434
+ *children,
435
+ use_math: bool | Var[bool] | bool = True,
436
+ use_gfm: bool | Var[bool] | bool = True,
437
+ use_unwrap_images: bool | Var[bool] | bool = True,
438
+ use_katex: bool | Var[bool] | bool = True,
439
+ use_raw: bool | Var[bool] | bool = True,
440
+ access_key: Var[str] | str | None = None,
441
+ auto_capitalize: Literal[
442
+ "characters", "none", "off", "on", "sentences", "words"
443
+ ]
444
+ | Var[Literal["characters", "none", "off", "on", "sentences", "words"]]
445
+ | None = None,
446
+ content_editable: Literal["inherit", "plaintext-only"]
447
+ | Var[Literal["inherit", "plaintext-only"] | bool]
448
+ | bool
449
+ | None = None,
450
+ context_menu: Var[str] | str | None = None,
451
+ dir: Var[str] | str | None = None,
452
+ draggable: Var[bool] | bool | None = None,
453
+ enter_key_hint: Literal[
454
+ "done", "enter", "go", "next", "previous", "search", "send"
455
+ ]
456
+ | Var[Literal["done", "enter", "go", "next", "previous", "search", "send"]]
457
+ | None = None,
458
+ hidden: Var[bool] | bool | None = None,
459
+ input_mode: Literal[
460
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
461
+ ]
462
+ | Var[
463
+ Literal[
464
+ "decimal", "email", "none", "numeric", "search", "tel", "text", "url"
465
+ ]
466
+ ]
467
+ | None = None,
468
+ item_prop: Var[str] | str | None = None,
469
+ lang: Var[str] | str | None = None,
470
+ role: Literal[
471
+ "alert",
472
+ "alertdialog",
473
+ "application",
474
+ "article",
475
+ "banner",
476
+ "button",
477
+ "cell",
478
+ "checkbox",
479
+ "columnheader",
480
+ "combobox",
481
+ "complementary",
482
+ "contentinfo",
483
+ "definition",
484
+ "dialog",
485
+ "directory",
486
+ "document",
487
+ "feed",
488
+ "figure",
489
+ "form",
490
+ "grid",
491
+ "gridcell",
492
+ "group",
493
+ "heading",
494
+ "img",
495
+ "link",
496
+ "list",
497
+ "listbox",
498
+ "listitem",
499
+ "log",
500
+ "main",
501
+ "marquee",
502
+ "math",
503
+ "menu",
504
+ "menubar",
505
+ "menuitem",
506
+ "menuitemcheckbox",
507
+ "menuitemradio",
508
+ "navigation",
509
+ "none",
510
+ "note",
511
+ "option",
512
+ "presentation",
513
+ "progressbar",
514
+ "radio",
515
+ "radiogroup",
516
+ "region",
517
+ "row",
518
+ "rowgroup",
519
+ "rowheader",
520
+ "scrollbar",
521
+ "search",
522
+ "searchbox",
523
+ "separator",
524
+ "slider",
525
+ "spinbutton",
526
+ "status",
527
+ "switch",
528
+ "tab",
529
+ "table",
530
+ "tablist",
531
+ "tabpanel",
532
+ "term",
533
+ "textbox",
534
+ "timer",
535
+ "toolbar",
536
+ "tooltip",
537
+ "tree",
538
+ "treegrid",
539
+ "treeitem",
540
+ ]
541
+ | Var[
542
+ Literal[
543
+ "alert",
544
+ "alertdialog",
545
+ "application",
546
+ "article",
547
+ "banner",
548
+ "button",
549
+ "cell",
550
+ "checkbox",
551
+ "columnheader",
552
+ "combobox",
553
+ "complementary",
554
+ "contentinfo",
555
+ "definition",
556
+ "dialog",
557
+ "directory",
558
+ "document",
559
+ "feed",
560
+ "figure",
561
+ "form",
562
+ "grid",
563
+ "gridcell",
564
+ "group",
565
+ "heading",
566
+ "img",
567
+ "link",
568
+ "list",
569
+ "listbox",
570
+ "listitem",
571
+ "log",
572
+ "main",
573
+ "marquee",
574
+ "math",
575
+ "menu",
576
+ "menubar",
577
+ "menuitem",
578
+ "menuitemcheckbox",
579
+ "menuitemradio",
580
+ "navigation",
581
+ "none",
582
+ "note",
583
+ "option",
584
+ "presentation",
585
+ "progressbar",
586
+ "radio",
587
+ "radiogroup",
588
+ "region",
589
+ "row",
590
+ "rowgroup",
591
+ "rowheader",
592
+ "scrollbar",
593
+ "search",
594
+ "searchbox",
595
+ "separator",
596
+ "slider",
597
+ "spinbutton",
598
+ "status",
599
+ "switch",
600
+ "tab",
601
+ "table",
602
+ "tablist",
603
+ "tabpanel",
604
+ "term",
605
+ "textbox",
606
+ "timer",
607
+ "toolbar",
608
+ "tooltip",
609
+ "tree",
610
+ "treegrid",
611
+ "treeitem",
612
+ ]
613
+ ]
614
+ | None = None,
615
+ slot: Var[str] | str | None = None,
616
+ spell_check: Var[bool] | bool | None = None,
617
+ tab_index: Var[int] | int | None = None,
618
+ title: Var[str] | str | None = None,
619
+ style: Sequence[Mapping[str, Any]]
620
+ | Mapping[str, Any]
621
+ | Var[Mapping[str, Any]]
622
+ | Breakpoints
623
+ | None = None,
624
+ key: Any | None = None,
625
+ id: Any | None = None,
626
+ ref: Var | None = None,
627
+ class_name: Any | None = None,
628
+ custom_attrs: dict[str, Any | Var] | None = None,
629
+ on_blur: EventType[()] | None = None,
630
+ on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
631
+ on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
632
+ on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
633
+ on_focus: EventType[()] | None = None,
634
+ on_mount: EventType[()] | None = None,
635
+ on_mouse_down: EventType[()] | None = None,
636
+ on_mouse_enter: EventType[()] | None = None,
637
+ on_mouse_leave: EventType[()] | None = None,
638
+ on_mouse_move: EventType[()] | None = None,
639
+ on_mouse_out: EventType[()] | None = None,
640
+ on_mouse_over: EventType[()] | None = None,
641
+ on_mouse_up: EventType[()] | None = None,
642
+ on_scroll: EventType[()] | None = None,
643
+ on_scroll_end: EventType[()] | None = None,
644
+ on_unmount: EventType[()] | None = None,
645
+ **props,
646
+ ) -> MarkdownWrapper:
647
+ """Create a markdown component.
648
+
649
+ Args:
650
+ *children: The children of the component.
651
+ use_math: Whether to use the remark-math plugin.
652
+ use_gfm: Whether to use the GitHub Flavored Markdown plugin.
653
+ use_unwrap_images: Whether to use the unwrap images plugin.
654
+ use_katex: Whether to use the KaTeX plugin.
655
+ use_raw: Whether to use the raw HTML plugin.
656
+ access_key: Provides a hint for generating a keyboard shortcut for the current element.
657
+ auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
658
+ content_editable: Indicates whether the element's content is editable.
659
+ context_menu: Defines the ID of a <menu> element which will serve as the element's context menu.
660
+ dir: Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
661
+ draggable: Defines whether the element can be dragged.
662
+ enter_key_hint: Hints what media types the media element is able to play.
663
+ hidden: Defines whether the element is hidden.
664
+ input_mode: Defines the type of the element.
665
+ item_prop: Defines the name of the element for metadata purposes.
666
+ lang: Defines the language used in the element.
667
+ role: Defines the role of the element.
668
+ slot: Assigns a slot in a shadow DOM shadow tree to an element.
669
+ spell_check: Defines whether the element may be checked for spelling errors.
670
+ tab_index: Defines the position of the current element in the tabbing order.
671
+ title: Defines a tooltip for the element.
672
+ style: The style of the component.
673
+ key: A unique key for the component.
674
+ id: The id for the component.
675
+ ref: The Var to pass as the ref to the component.
676
+ class_name: The class name for the component.
677
+ custom_attrs: Attributes passed directly to the component.
678
+ on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
679
+ on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
680
+ on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
681
+ on_context_menu: Fired when the user right-clicks on an element.
682
+ on_double_click: Fired when the user double-clicks on an element.
683
+ on_mouse_down: Fired when the user presses a mouse button on an element.
684
+ on_mouse_enter: Fired when the mouse pointer enters the element.
685
+ on_mouse_leave: Fired when the mouse pointer leaves the element.
686
+ on_mouse_move: Fired when the mouse pointer moves over the element.
687
+ on_mouse_out: Fired when the mouse pointer moves out of the element.
688
+ on_mouse_over: Fired when the mouse pointer moves onto the element.
689
+ on_mouse_up: Fired when the user releases a mouse button on an element.
690
+ on_scroll: Fired when the user scrolls the element.
691
+ on_scroll_end: Fired when scrolling ends on the element.
692
+ on_mount: Fired when the component is mounted to the page.
693
+ on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
694
+ **props: The properties of the component.
695
+
696
+ Returns:
697
+ The markdown component or div wrapping markdown component.
698
+
699
+ Raises:
700
+ ValueError: If the children are not valid.
701
+ """
702
+
703
+ markdown = MarkdownNamespace()