Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Simple piece of code

To display a piece of code, use the following syntax:

```javascript
var a = 2;
var b = 4;
console.log(a+b);
```

javascript specifies the language so that the syntax is correctly highlighted.

Auto fold

You can auto fold some sections of your code by using this syntax:

// { autofold
  code which is collapsed
// }

visible code

Runnable snippet

Syntax

For basic usage, you can make a simple piece of code runnable. To do that you need to create a piece of code by using the standard markdown syntax and then add the runnable keyword:

```javascript runnable
var a = 2;
var b = 4;
console.log(a+b);
```

renders as

Compatible languages

This simple syntax is a shortcut for a given language that automatically selects a runner and a command.

Here you can find a table that summarizes the supported languages and the associated docker image, command and filename.

LanguageDocker imagecommand filename
adawalleza1/ada-gnatmake:latestgnatmake main.adb && ./mainmain.adb
javajava:latestbash -c "javac Main.java" && java Main"Main.java
 javascriptnode:latestnode index.js index.js
pythonpython:latestpython main.py main.py
bashbash:latestbash main.sh main.sh
Cgcc:latestbash -c "gcc main.c -o exe && ./exe" main.c
C#mono:5bash -c "mcs main.cs && mono main.exe" main.cs
C++gcc:latestbash -c "g++ main.cc -o exe && ./exe" main.cc
dartgoogle/dart:latestdart main.dart main.dart
elixirelixir:latestelixir main.exs main.exs
F#mono5:latestbash -c "fsharpc --nologo main.fs && mono main.exe" main.fs
gogolang:latestgo run main.go main.go
groovygroovy:latestgroovy main.groovy main.groovy
haskellhaskell:latestbash -c "ghc main.hs -o exe && ./exe" main.hs
htmlubuntu:latestecho "TECHIO> open -s /project/target index.html" index.html
kotlintechio/kotlin-snippet-runner:latestkotlin-compiler-runner.sh main.ktmain.kt
perlperl:latestperl main.pl main.pl
phpphp:latestphp main.php main.php
Rr-base:latestRscript main.R main.R
rubyruby:latestruby main.rb main.rb
rustrust:latestbash -c "rustc main.rs && ./main" main.rs
scalatechio/scala-sbt:2.12bash -c "scalac Main.scala && scala Main" Main.scala
swiftswift:latestswift main.swift main.swift
vb.netmono:5bash -c "vbnc /nologo main.vb && mono main.exe" main.vb

For any language in the language column you can create a snippet by specifying the language and the keyword runnable as seen before.

When the user presses the Run button, it automatically saves this piece of code in a file (filename column) stored in the specific docker image and then executes the command.

If you want us to add new language extension, feel free to contact us by giving us all required data (docker image, command, filename): community@tech.io

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content