Git Product home page Git Product logo

tourkaman / obsidian-code-emitter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mokeyish/obsidian-code-emitter

0.0 0.0 0.0 992 KB

An obsidian plugin that allows code blocks executed interactively in sandbox like jupyter notebooks. Supported language rust、kotlin、python、Javascript、TypeScript etc.

License: GNU General Public License v3.0

JavaScript 2.61% TypeScript 86.14% CSS 0.24% Svelte 11.01%

obsidian-code-emitter's Introduction

Obsidian Code Emitter

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

This plugin allows code blocks executed interactively like jupyter notebooks. It is based on HTTP REST APIs and JS sandbox and Webassembly technology, and has no local environment requirements, so it supports all platforms supported by Obsidian.

Supports all Obsidian supported platforms, includes:

  • Windows
  • MacOS
  • Linux
  • Android
  • IOS

Currently, support languages:

Supported language Way
Rust https://play.rust-lang.org
Kotlin https://play.kotlinlang.org
V https://play.vosca.dev/
JavaScript JS Sandbox (qiankun)
TypeScript[] TypeScript Compiler + JS Sandbox
Wenyan Wenyan Compiler + JS Sandbox
Python WebAssembly (Pyodide)
Java Sololearn
Go Sololearn
c/c++ Sololearn
CSharp Sololearn
Swift Sololearn
R Sololearn

Note: Only PythonTypeScriptJavaScript are run locally in sandbox(js / webassembly). Other's will send code to third-party website to eval the results (eg: 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 of obsidian, and install it.

Examples

Python

Install numpy through micropip. All available packages are list in here (search whl).

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)

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

obsidian-code-emitter's People

Contributors

mokeyish avatar github-actions[bot] avatar flippingbinary avatar seiimonn avatar zhymabekroman avatar nicosup98 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.