{"id":29193440,"url":"https://github.com/bencode/logseq-runit-plugin","last_synced_at":"2025-08-02T23:08:17.072Z","repository":{"id":300897140,"uuid":"1007484407","full_name":"bencode/logseq-runit-plugin","owner":"bencode","description":"A Logseq plugin for running code","archived":false,"fork":false,"pushed_at":"2025-07-01T12:33:16.000Z","size":3793,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-01T13:23:32.627Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bencode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T04:35:25.000Z","updated_at":"2025-07-01T12:32:14.000Z","dependencies_parsed_at":"2025-06-24T06:35:51.489Z","dependency_job_id":"715a2a35-e780-4ce1-a020-f1b8d6d8924f","html_url":"https://github.com/bencode/logseq-runit-plugin","commit_stats":null,"previous_names":["bencode/logseq-runit-plugin"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bencode/logseq-runit-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencode%2Flogseq-runit-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencode%2Flogseq-runit-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencode%2Flogseq-runit-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencode%2Flogseq-runit-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bencode","download_url":"https://codeload.github.com/bencode/logseq-runit-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bencode%2Flogseq-runit-plugin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263064196,"owners_count":23408082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-07-02T02:31:50.324Z","updated_at":"2025-08-02T23:08:17.061Z","avatar_url":"https://github.com/bencode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# logseq-runit-plugin\n\nA Logseq plugin for running code snippets directly inside your notes.  \nSupports JavaScript, Python (via [Pyodide](https://pyodide.org/)), Scheme (via [BiwaScheme](https://www.biwascheme.org/)), and Clojure (via [SCI](https://github.com/babashka/sci)) with interactive output.  \nBuilt for [Logseq](https://logseq.com/).\n\n![Demo](images/p2.gif)\n\n## Features\n\n- **Multi-language support**: Run JavaScript, Python, Scheme, and Clojure code blocks\n- **Console output capture**: See `console.log`/`print` output inline\n- **Last expression result**: Automatically displays the result of the last expression, similar to Jupyter notebooks\n- **Dynamic imports**: Supports dynamic module imports for JavaScript\n- **Easy insertion**: Use the `/Create Runit Snippet` slash command to insert runnable code blocks\n\n## Installation\n\nInstall the plugin directly from the Logseq Marketplace:\n\n1. Open Logseq\n2. Go to Settings → Plugins\n3. Click \"Marketplace\" \n4. Search for \"runit\"\n5. Click \"Install\" on the logseq-runit-plugin\n\n## Usage\n\n1. Use the `/Create Runit Snippet` command to insert a code block\n2. Write your code in JavaScript, Python, Scheme, or Clojure inside the block\n3. The output and console logs will be displayed below the code\n\n**Note:** When using the `/Create Runit Snippet` command, ensure the generated macro remains attached to the current block. Use Shift+Enter for line breaks within the same block before running the slash command, rather than creating a new separate block.\n\n### Importing External JavaScript Modules\n\nYou can import external JavaScript modules using the `$import` function:\n\n```js\nconst R = await $import('https://esm.sh/ramda')\n\nR.map(v =\u003e v + 1)([1, 2, 3, 4])\n\n// output\nArray [\n  2,\n  3,\n  4,\n  5,\n]\n```\n\nThe `$import` function supports both URLs and module names, allowing you to use libraries from CDNs like [esm.sh](https://esm.sh/) directly in your code snippets.\n\n### Google Charts Integration\n\nYou can create interactive charts using Google Charts:\n\n```js\nconst chart = await $import('google-charts')\nconst data = [\n  ['Task', 'Hours per Day'],\n  ['Work',     11],\n  ['Eat',      2],\n  ['Commute',  2],\n  ['Watch TV', 2],\n  ['Sleep',    7]\n]\nconst options = {\n  title: 'My Daily Activities',\n  width: 500,\n  height: 300\n}\nchart.render('PieChart', data, options)\n```\n\n![GoogleCharts](images/p3.svg)\n\nThe Google Charts integration supports various chart types including PieChart, BarChart, LineChart, ScatterChart, Gauge, GeoChart, and Table. Charts are rendered as interactive SVG elements directly in your notes.\n\nFor more chart types and configuration options, see the [Google Charts Gallery](https://developers.google.com/chart/interactive/docs/gallery).\n\n### Python Support\n\nThe plugin supports running Python code via [Pyodide](https://pyodide.org/), bringing the full Python scientific computing stack to your browser.\n\n#### Basic Python Usage\n\n```python\n#% pip install numpy\n\nimport numpy as np\n\n# Create a simple array\narr = np.array([1, 2, 3, 4, 5])\nprint(\"Array:\", arr)\nprint(\"Sum:\", np.sum(arr))\nprint(\"Mean:\", np.mean(arr))\n\n# Return the result\narr * 2\n```\n\n#### Creating Plots with Matplotlib\n\n```python\n#% pip install matplotlib numpy\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n# Create data\nx = np.linspace(0, 10, 100)\ny1 = np.sin(x)\ny2 = np.cos(x)\n\n# Create the plot\nplt.figure(figsize=(10, 6))\nplt.plot(x, y1, 'b-', linewidth=2, label='sin(x)')\nplt.plot(x, y2, 'r--', linewidth=2, label='cos(x)')\nplt.xlabel('x')\nplt.ylabel('y')\nplt.title('Trigonometric Functions')\nplt.grid(True, alpha=0.3)\nplt.legend()\n\n# Render the plot\nplt_show()\n```\n\n![Python Plot Example](images/p5.svg)\n\n### Scheme Support\n\nThe plugin supports running Scheme code snippets via BiwaScheme, allowing you to execute and view results conveniently in your notes:\n\n```scheme\n(define (fib n)\n  (if (\u003c n 2) n\n      (+ (fib (- n 1)) (fib (- n 2)))))\n(fib 8)\n```\n\n### Clojure Support\n\nThis plugin supports running Clojure code snippets via sci (Small Clojure Interpreter), allowing you to execute ClojureScript code directly in your notes:\n\n```clojure\n(defn factorial [n]\n  (if (\u003c= n 1)\n    1\n    (* n (factorial (dec n)))))\n\n(factorial 5)\n```\n\nSCI provides a safe, sandboxed environment for executing Clojure code with most of the core ClojureScript functionality available.\n\n## Development\n\n- Clone the repo and run `pnpm install`\n- Use `pnpm dev` to start development with hot reload\n- Build for production with `pnpm build`\n\n## Acknowledgments\n\nSpecial thanks to [Klipse](https://github.com/viebel/klipse) for inspiration.  \nOriginally, I wanted to integrate Klipse directly, but due to some technical limitations, I implemented a simplified \"code runner\" based on some of Klipse's ideas.  \n\n**Note:** Currently, code execution happens when the code editor loses focus, which is less interactive compared to Klipse.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencode%2Flogseq-runit-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbencode%2Flogseq-runit-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbencode%2Flogseq-runit-plugin/lists"}