A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
improvement: Realtime Markdown rendering (#2138)
Wasim Sandhu49d0dd4d5d59
diff --git a/frontend/src/core/codemirror/cells/extensions.ts b/frontend/src/core/codemirror/cells/extensions.tsindex 60276de9f5..1719c0aede 100644--- a/frontend/src/core/codemirror/cells/extensions.ts+++ b/frontend/src/core/codemirror/cells/extensions.ts@@ -310,3 +310,16 @@ export function cellCodeEditingBundle(return [onChangePlugin, formatKeymapExtension(cellId, callbacks, hotkeys)];}++/**+ * Extension for auto-running markdown cells+ */+export function markdownAutoRunExtension(+ callbacks: MovementCallbacks,+): Extension {+ return EditorView.updateListener.of((update) => {+ if (update.docChanged) {+ callbacks.onRun();+ }+ });+}diff --git a/frontend/src/core/codemirror/language/markdown.ts b/frontend/src/core/codemirror/language/markdown.tsindex 42789f5644..e9fae8e790 100644--- a/frontend/src/core/codemirror/language/markdown.ts+++ b/frontend/src/core/codemirror/language/markdown.ts@@ -17,6 +17,11 @@ import type { CompletionConfig } from "@/core/config/config-schema";import type { HotkeyProvider } from "@/core/hotkeys/hotkeys";import { indentOneTab } from "./utils/indentOneTab";import { type QuotePrefixKind, splitQuotePrefix } from "./utils/quotes";+import {+ markdownAutoRunExtension,+ type MovementCallbacks,+} from "../cells/extensions";+import type { PlaceholderType } from "../config/extension";const quoteKinds = [['"""', '"""'],@@ -136,6 +141,8 @@ export class MarkdownLanguageAdapter implements LanguageAdapter {getExtension(_completionConfig: CompletionConfig,hotkeys: HotkeyProvider,+ _: PlaceholderType,+ movementCallbacks: MovementCallbacks,): Extension[] {return [markdown({@@ -174,6 +181,8 @@ export class MarkdownLanguageAdapter implements LanguageAdapter {activateOnTyping: true,override: [emojiCompletionSource],}),+ // Markdown autorun+ markdownAutoRunExtension(movementCallbacks),python().support,];}diff --git a/frontend/src/css/globals.css b/frontend/src/css/globals.cssindex 6f38e4048a..5ada1b2b16 100644--- a/frontend/src/css/globals.css+++ b/frontend/src/css/globals.css@@ -66,7 +66,6 @@--stale: hsl(42deg 56% 44% / 25%);--ring: hsl(215deg 20.2% 65.1%);--radius: 8px;---base-shadow: hsl(0deg 0% 85% / 40%);--base-shadow-darker: hsl(0deg 0% 50% / 40%);--base-shadow-opacity: 5%;@@ -101,7 +100,7 @@--link-visited: hsl(272deg 51% 74%); /* purple-9 *//* Base shadows. */- --base-shadow: hsla(0 0% 36% / 60%);+ --base-shadow: hsla(0deg 0% 36% / 60%);--base-shadow-darker: hsl(0deg 0% 50% / 60%);--base-shadow-opacity: 85%;}diff --git a/marimo/_smoke_tests/bugs/2137-realtime-markdown.py b/marimo/_smoke_tests/bugs/2137-realtime-markdown.pynew file mode 100644index 0000000000..702938e429--- /dev/null+++ b/marimo/_smoke_tests/bugs/2137-realtime-markdown.py@@ -0,0 +1,47 @@+import marimo++__generated_with = "0.8.3"+app = marimo.App()+++def __():+ import marimo as mo+ import time+ return mo, time+++def __(time):+ time.sleep(10)+ return+++def __(mo):+ mo.md(+ r"""+ ### Realtime Markdown Editing+ Everything you type should update the cell output in realtime, which is pretty cool!++ | Feature | Description |+ |-------------------|--------------------------------------------------------|+ | Compact Size | Small and versatile for display in various containers. |+ | Easy Maintenance | Requires minimal care and indirect sunlight. |+ | Unique Appearance | Spherical and soft, visually distinct. |+ | Oxygen Production | Helps oxygenate aquatic environments. |+ | Slow Growth | Grows about 5 mm per year, keeping size manageable. |+ | Longevity | Can live for many years, even over a century. |+ | Cultural Symbol | In Japan, seen as good luck charms. |+ | Adaptable | Thrives in various water conditions. |+ | Non-Invasive | Won't overtake the environment like other plants. |+ | Eco-Friendly | Sustainable and environmentally safe. |++ + """+ )+ return+++if __name__ == "__main__":+ app.run()