mirror of
https://github.com/ohm-engineering/obsidian-csharp-interactive.git
synced 2026-07-22 19:20:30 +00:00
Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c840d3e3d7 | ||
|
|
6c6553b41b | ||
|
|
1118b80ccf | ||
|
|
b8c899bdbe | ||
|
|
0684cdc0bb | ||
|
|
c6bd967ba3 | ||
|
|
c6cdd54672 | ||
|
|
ceafe637a7 | ||
|
|
ab337f6194 |
6 changed files with 36 additions and 9 deletions
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
|
|
@ -9,7 +9,9 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
attestations: write
|
||||||
contents: write
|
contents: write
|
||||||
|
id-token: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
|
@ -23,6 +25,13 @@ jobs:
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
- name: Attest release artifacts
|
||||||
|
uses: actions/attest-build-provenance@v2
|
||||||
|
with:
|
||||||
|
subject-path: |
|
||||||
|
main.js
|
||||||
|
styles.css
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
2
LICENSE
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (C) 2020-2025 by Dynalist Inc.
|
Copyright (C) 2026 OHM Engineering.
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
||||||
|
|
||||||
|
|
|
||||||
18
README.md
18
README.md
|
|
@ -1,6 +1,9 @@
|
||||||
# C# Snippet Runner
|
# CSharp Snippet Runner
|
||||||
|
|
||||||
|
Obsidian plugin that adds a run button to C# code blocks. It uses [CSharpRepl](https://github.com/waf/CSharpRepl) to execute the snippets and displays the output directly in the note.
|
||||||
|
|
||||||
|
<img width="960" height="487" alt="Schermafbeelding 2026-05-29 110157" src="https://github.com/user-attachments/assets/233e5535-0cf4-4c75-ba27-8af9a36315ec" />
|
||||||
|
|
||||||
Obsidian plugin that adds a run button to C# code blocks. It uses CSharpRepl to execute the snippets and displays the output directly in the note.
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
@ -11,6 +14,17 @@ Obsidian plugin that adds a run button to C# code blocks. It uses CSharpRepl to
|
||||||
- Saves output and arguments per snippet in the plugin `responses` folder
|
- Saves output and arguments per snippet in the plugin `responses` folder
|
||||||
- Restores saved output/arguments when notes are rendered
|
- Restores saved output/arguments when notes are rendered
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
- Obsidian version >= 1.12.7
|
||||||
|
- [dotnet SDK](https://dotnet.microsoft.com/en-us/download) installed on your PC
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
- Add a code snippet to your Obsidian note with one of these tags: `csharp`, `cs`, `c#`, `net`, `.net` or `dotnet`
|
||||||
|
- Optionally enter args
|
||||||
|
- Click `Run C#`
|
||||||
|
|
||||||
|
See [CSharpRepl](https://github.com/waf/CSharpRepl) on how to use with includes and nuget packages
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"id": "csharp-snippet-runner",
|
"id": "csharp-snippet-runner",
|
||||||
"name": "CSharp Snippet Runner",
|
"name": "CSharp Snippet Runner",
|
||||||
"version": "1.0.0",
|
"version": "1.0.4",
|
||||||
"minAppVersion": "1.12.7",
|
"minAppVersion": "1.12.7",
|
||||||
"description": "Run C# code blocks in Obsidian using an auto-installed CSharpRepl runtime.",
|
"description": "Run C# code blocks using an auto-installed CSharpRepl runtime.",
|
||||||
"author": "OHM Engineering",
|
"author": "OHM Engineering",
|
||||||
"authorUrl": "https://github.com/OHM-Engineering",
|
"authorUrl": "https://github.com/OHM-Engineering",
|
||||||
"isDesktopOnly": false
|
"isDesktopOnly": false
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,11 @@ export default class CSharpSnippetRunnerPlugin extends Plugin {
|
||||||
clearTimeout(timeoutHandle);
|
clearTimeout(timeoutHandle);
|
||||||
|
|
||||||
if (timedOut) {
|
if (timedOut) {
|
||||||
resolve({ stdout, stderr });
|
const timeoutError = new Error(`CSharpRepl execution timed out after ${timeoutMs}ms. Increase the timeout setting and try again.`) as ReplExecutionError;
|
||||||
|
timeoutError.code = 'ETIMEDOUT';
|
||||||
|
timeoutError.stdout = stdout;
|
||||||
|
timeoutError.stderr = stderr;
|
||||||
|
reject(timeoutError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export interface CSharpSnippetSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_SETTINGS: CSharpSnippetSettings = {
|
export const DEFAULT_SETTINGS: CSharpSnippetSettings = {
|
||||||
executionTimeoutMs: 3000,
|
executionTimeoutMs: 10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
export class CSharpSnippetSettingTab extends PluginSettingTab {
|
export class CSharpSnippetSettingTab extends PluginSettingTab {
|
||||||
|
|
@ -29,7 +29,7 @@ export class CSharpSnippetSettingTab extends PluginSettingTab {
|
||||||
.setName('Execution timeout (ms)')
|
.setName('Execution timeout (ms)')
|
||||||
.setDesc('Maximum time to wait before stopping execution and returning captured output.')
|
.setDesc('Maximum time to wait before stopping execution and returning captured output.')
|
||||||
.addText((text) => text
|
.addText((text) => text
|
||||||
.setPlaceholder('3000')
|
.setPlaceholder('10000')
|
||||||
.setValue(String(this.plugin.settings.executionTimeoutMs))
|
.setValue(String(this.plugin.settings.executionTimeoutMs))
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
const parsed = Number.parseInt(value, 10);
|
const parsed = Number.parseInt(value, 10);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue