Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute custom script for unsupported languages #251

Open
nnzv opened this issue Jun 11, 2023 · 4 comments
Open

Execute custom script for unsupported languages #251

nnzv opened this issue Jun 11, 2023 · 4 comments

Comments

@nnzv
Copy link

nnzv commented Jun 11, 2023

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
@nnzv
Copy link
Author

nnzv commented Jun 11, 2023

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
```

@jrrom
Copy link

jrrom commented Sep 21, 2023

I would personally also like to see this feature.

@suynep
Copy link

suynep commented Mar 28, 2024

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

Would love to see this implementation!

@nnzv
Copy link
Author

nnzv commented May 10, 2024

CC @maaslalani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants