Skip to content

benabineri/kotlin-runcode

 
 

Repository files navigation

official JetBrains project

Kotlin Run Code

Self-contained component to embed in websites for running Kotlin code. It converts HTML code blocks to editable and runnable editor.

Usage

Quickly from CDN

Insert <script> tag into the page and specify code blocks selector to attach via data-selector HTML attribute.

<script src="https://unpkg.com/kotlin-runcode@1/dist/runcode.min.js" data-selector="code"></script>

Selector option is required.

Manually from NPM

Install KotlinRunCode as dependency.

npm install kotlin-runcode -S

Use it in your code.

// ES5
var runcode = require('kotlin-runcode');

document.addEventListener('DOMContentLoaded', function() {
  runcode('code'); // attach to all <code> elements
});


// ES6
import runcode from 'kotlin-runcode';

document.addEventListener('DOMContentLoaded', () => {
  runcode('code'); // attach to all <code> elements
});

Configuration

TODO

Configure specific code block

Following HTML attributes are supported.

Make editable only part of the code

If you want to highlight a specific area to focus on a specific sample, use //sampleStart and //sampleEnd markers:

<code>
fun main(name: String) {
   println("Hello $name")
}

//sampleStart
fun sum(a: Int, b: Int): Int {
  return a + b
}
//sampleEnd
</code>

Development

  1. Fork & clone a repository (how to).
  2. Install dependencies npm install.
  3. Following commands are available:
    • npm start to run a local development server at http://localhost:9000.
      • Custom WebDemo URL - npm start -- --env.webDemoUrl=http://localhost:6666.
    • npm run build to build a production bundle.

About

Self-contained component to embed in websites for running Kotlin code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 83.8%
  • CSS 16.2%