Skip to content

Latest commit

 

History

History
214 lines (151 loc) · 2.2 KB

File metadata and controls

214 lines (151 loc) · 2.2 KB

Code blocks

Slides allows you to execute code blocks directly inside your slides!

Just press ctrl+e and the result of the code block will be displayed as virtual text in your slides.

Currently supported languages:

  • bash
  • zsh
  • fish
  • elixir
  • go
  • javascript
  • python
  • ruby
  • perl
  • rust
  • java
  • cpp
  • swift
  • dart
  • v
  • nu

Bash

ls

Zsh

ls

Fish

ls

Elixir

IO.puts "Hello, world!"

Go

Use /// to hide verbose code but still allow the ability to execute it.

If you press y to copy (yank) this code block it will return the full snippet.

And, if you press ctrl+e it will run the program without error, even though what is being displayed is not a valid go program because we have commented out some boilerplate to focus on the important parts.

///package main
///
import "fmt"
///
///func main() {
fmt.Println("Hello, world!")
///}

Javascript

console.log("Hello, world!")

Lua

print("Hello, World!")

Python

print("Hello, world!")

Ruby

puts "Hello, world!"

Perl

print ("hello, world");

Rust

fn main() {
    println!("Hello, world!");
}

Java

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Julia

println("Hello, world!")

C++

#include <iostream>

int main() {
    std::cout << "Hello, world!" << std::endl;
    return 0;
}

Swift

print("Hello, world!")

Dart

void main() {
  print("Hello, world!");
}

V

println('Hello, world!')

Scala

//> using dep com.lihaoyi::pprint:0.8.1

object Main extends App {
  println("Hello")
}

Nushell

# Basic string output
echo "Hello from Nushell!"
# Data manipulation with pipelines
[1, 2, 3, 4, 5] | where $it > 2 | math sum
# Working with records
{name: "Alice", age: 30, city: "New York"} | get name