Code Emitter

by YISH
5
4
3
2
1
Score: 54/100

Description

Category: Coding & Technical Tools

The Code Emitter plugin transforms Obsidian into an interactive coding environment similar to Jupyter Notebooks. It allows users to execute code blocks within notes across multiple programming languages, including Python, JavaScript, TypeScript, HTML, and CSS, as well as others like Rust, Kotlin, and C++. Code can run locally via JavaScript or WebAssembly sandboxes or be processed on third-party platforms, depending on the language. This functionality is available on all platforms supported by Obsidian, including desktop and mobile. The plugin is particularly useful for developers, educators, and learners who want to integrate live coding and algorithm testing into their Obsidian workflow.

Reviews

No reviews yet.

Stats

384
stars
61,758
downloads
21
forks
1,201
days
508
days
508
days
121
total PRs
10
open PRs
95
closed PRs
16
merged PRs
54
total issues
37
open issues
17
closed issues
23
commits

Latest Version

a year ago

Changelog

What's Changed

New Contributors

Full Changelog: https://github.com/mokeyish/obsidian-code-emitter/compare/0.3.3...0.4.0

README file from

Github

Obsidian Code Emitter

GitHub release (latest by date including pre-releases) GitHub all releases

This plugin allows code blocks to be executed interactively like in Jupyter Notebooks. It has no external environment requirements (such as system installations of compilers), because code execution works via local sandboxes using JavaScript or WebAssembly technology, or network requests to online Playgrounds. This means it can support all platforms supported by Obsidian.

Supports all Obsidian supported platforms, including:

  • Windows
  • macOS
  • Linux
  • Android
  • iOS

Supported languages:

Language Provider
C/C++ Sololearn
C# Sololearn
Go Sololearn
Haskell https://play.haskell.org
HTML & CSS Shadow DOM
Java Sololearn
JavaScript JS Sandbox (qiankun)
Kotlin https://play.kotlinlang.org
Python WebAssembly (Pyodide)
R Sololearn
Rust https://play.rust-lang.org
Swift Sololearn
TypeScript TypeScript Compiler + JS Sandbox
V https://play.vosca.dev/
Wenyan Wenyan Compiler + JS Sandbox

[!NOTE]
Only Python, TypeScript, and JavaScript are run in a local sandbox (JS/WebAssembly). Others will send code to third-party website to evaluate the results (e.g.: https://play.kotlinlang.org, https://play.rust-lang.org). Please take care to avoid sending your potentially-sensitive source code.

Ads: You might like my other plugins 🤪


.

Installation

  1. Search Code Emitter in the Community plugins section of Obsidian, and install it.

Examples

Python

Install numpy through micropip. All available packages are listed here (search for whl).

Using numpy
import micropip
await micropip.install('numpy')  
import numpy as np
a = np.random.rand(3,2)
b = np.random.rand(2,5)

print(a@b)
Using matplotlib
import micropip
await micropip.install('matplotlib')

import matplotlib.pyplot as plt

fig, ax = plt.subplots()             # Create a figure containing a single Axes.
ax.plot([1, 2, 3, 4], [1, 4, 2, 3])  # Plot some data on the Axes.
plt.show()                           # Show the figure.

HTML & CSS

<div><span class="h">Hello</span><span class="w">world</span></div>

<style>
.h {
  color: red;
}
.w {
  color: green;
}
</style>

Any languages that support CORS

Here is the example to support Ruby.

const url = 'https://api2.sololearn.com/v2/codeplayground/v2/compile';

const runCode = async (code: string, lang: 'cpp' | 'go' | 'c' | 'java' | 'cs' | 'swift' | 'rb') => {
  const header = {
    'User-Agent': 'Obsidian Code Emitter/0.1.0 (If this is not allowed, please let me know)',
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'en-US',
    'Content-Type': 'application/json',
  };

  const res = await fetch(url, {
    'headers': header,
    'body': JSON.stringify({
      'code': code,
      'codeId': null,
      'input': '',
      'language': lang
    }),
    'method': 'POST',
  });
  return (await res.json()) as {
    success: boolean,
    errors: string[],
    data: {
      sourceCode: number,
      status: number,
      errorCode: number,
      output: string,
      date: string,
      language: string,
      input: string,
    }
  };
};

const ruby_code = `
puts "Hello World12"
`;


console.log((await runCode(ruby_code, 'rb')).data.output);

License

This plugin sandbox contains codes from https://github.com/umijs/qiankun, which is licensed under

And other codes is licensed under

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Format code blocks of various languages
4 years ago by iVariable
Execute Code
4 years ago by twibiral
Obsidian Plugin to execute code in a note.
RunJS
3 years ago by eoureo
Let's run JavaScript easily and simply in Obsidian.
Exercises
3 years ago by AlexCCavaco
Create Interactive Exercises along side your Obsidian Notes
JS Engine
3 years ago by Moritz Jung
An Obsidian plugin that offers a multiple ways to run JavaScript from within Obsidian.
Graphs
2 years ago by Dylan Hojnoski
Plugin for Obsidian that renders interactive graphs from YAML.
Lean Syntax Highlight
2 years ago by tomaz1502
A plugin for Obsidian that provides syntax highlight for Lean.
Charts
5 years ago by phibr0
Charts - Obsidian Plugin | Create editable, interactive and animated Charts in Obsidian via Chart.js
Leaflet
5 years ago by Jeremy Valentine
Adds interactive maps to Obsidian.md using Leaflet.js
Juggl
5 years ago by Emile van Krieken
An interactive, stylable and expandable graph view for Obsidian. Juggl is designed as an advanced 'local' graph view, where you can juggle all your thoughts with ease.
Poker Range
2 years ago by marplek
Easily create, view, and interact with poker hand ranges in your obsidian.
Masking Type
a year ago by Telehakke
Obsidian plugin.
Easy Test
a year ago by Forrest
New 3D Graph
9 months ago by Aryan Gupta
Visualize your vault in 3D with a powerful, highly customizable, and filterable graph.
Table Checkbox Renderer
5 months ago by Daniel Aguerrevere
Interactive checkboxes for Markdown tables in Obsidian. Toggle checkboxes in Reading Mode and instantly update your Markdown file. Supports multiple checkboxes per cell and any table layout.