maaslalani / slides

Terminal based presentation tool

Home Page:http://maaslalani.com/slides/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Execute custom script for unsupported languages

nnzv opened this issue · comments

Is your feature request related to a problem? Please describe

Users often encounter the need to execute code blocks in Slides that are written in unsupported languages. It becomes a limitation when presenting code examples or demonstrations.

Describe the solution you'd like

Support custom shell scripts as hooks for executing code blocks in unsupported languages. This would allow users to define their own scripts to handle the execution of code in any language.

Describe alternatives you've considered

One alternative solution is to manually copy and paste code into a separate terminal or IDE to execute it. However, this disrupts the flow of the presentation and requires switching between different tools.

Additional context

As an example, consider the following shell script that could be used as a custom hook for executing code blocks written in the PlantUML language:

#!/usr/bin/env bash

# Read the code block content from the first argument
code_block="$1"
# Read the code block name from the second argument
code_block_name="$2"
# Execute logic based on the code block name
case "$code_block_name" in
    "plantuml")
        # Generate PlantUML diagram image from the code block content
        graph="$(mktemp).png"
        echo "$code_block" | plantuml -tpng -p > $graph
        # Open the png file using the sxiv image viewer
        sxiv $graph
        ;;
    *)
        echo "Unsupported language: $code_block_name"
        ;;
esac

To implement this feature, users would include the invoker attribute in the front-matter of the Markdown file, specifying the path to their custom executor script. Here's an example:

---
invoker: /path/to/script
---

# Understanding Deployments

Relationship between a Deployment and a ReplicaSet

```plantuml
@startuml
:Deployment;
-> Create 2 Replicas;
:Replicaset;
-> Maintain;
:2 Pods;
@enduml
```

I would personally also like to see this feature.

Hi, I've been trying to compile and execute C code within slides and found this issue interesting

Would love to see this implementation!