Thin wrapper around Rant-Lang for Obsidian.md

Overview

Obsidian Rant-Lang

GitHub release (latest SemVer) GitHub all releases

Thin wrapper around the Rant language Rust crate to be used in Obsidian.

"Rant is a high-level procedural templating language with a diverse toolset for easily creating dynamic code templates, game dialogue, stories, name generators, test data, and much more." - from Rant's GitHub page

Table of Contents

Usage

Use a code block with the rant type, in which you can enter a Rant program. The program is then compiled and executed with Rant, and the result shown in the Obsidian preview mode.

Use the command Re-rant with random seed (active file) (default hotkey: Cmd+R/Ctrl+R) to run Rant again on each block in the active (preview) file.

It's also possible to insert a Rant program inline by starting an inline code block with "rant:".

Within a rant block (both inline and code blocks), the result of the program is then rendered with the Obsidian MarkdownParser. That means that you can add styling, links, or other markdown-processing elements inside a rant block, and they will be rendered accordingly. In order to avoid Rant syntax errors, you can wrap these elements in double quotes, because Rant treats everything inside double quotes as string literals, and will not evaluate the content.

You can also embed the result of an existing rant codeblock into any other document or other rant block by using block links, see these examples for details.

Examples

Note: As Rant chooses random block elements to run, the output of the following examples will vary with each re-run of Rant, so what's shown here is just one possible result.

A Rant program that produces a shuffled deck of cards, taken from the official Rant examples:

```rant
[shuffled: 
  [rep: 2] {(Joker)} 
  [cat: **(A;2;3;4;5;6;7;8;9;10;J;Q;K); **(♠;♥;♣;♦) |> collect]
]
```

Could produce this output (with a random order on each re-rant):

Cards example

Inline

An inline Rant program:

This inline Rant block is `rant: {neat|awesome|fantastic}`!

Result:

Inline example

Styling

This is an example of how to apply markdown styling within the Rant code block, note the usage of double quotes:

```rant
"**"{Hello|Hi|Hey}"**" world!
```

Result:

Styling example

Links

You can use any form of links within a Rant code block, and it properly renders (including page preview on hover):

```rant
[rep:10][sep:"-"]{"[[A Page]]"|"[External link](https://www.wikipedia.org)"|Just text}
```

Result:

Link example

Dice-roller

Example using the dice-roller plugin within a Rant block:

```rant
Suddenly "`dice: 2d4`" {goblins|dragons|gelatinous cubes} charge at you!
```

Result:

Dice-roller example

Lists

A Rant program can output lists like this:

```rant
A list of all kinds of stuff:\n
[rep:5][sep:\n]{"- [[A page]]"|"- Just text"|"- `dice: 2d12`"}
```

Result:

List example

Embedding Rant Blocks

Inline

When you have a rant codeblock inside a document called Programs that you want to embed in another document, first give it an ID using the ^ notation:

```rant
{heads|tails|edge}
```
^coin-flip

Then you can embed it like so:

Flipping a coin... It landed on `rant: [[Programs#^coin-flip]]`!

Within codeblocks

Inside a rant codeblock, you can import rant codeblocks from other documents by starting the codeblock with import: [[File#^{block-id}]] statements.

Important: import: statements can only be used as very first lines in a rant codeblock. Once any line does not begin with import:, the regular rant program starts, and you can't import anything else. One import per line.

Here is an example, we define rant blocks that define functions, import the block, and call the functions:

```rant
[$flip-coin: heads; tails] {
    {<heads>|<tails>}
}
```
^flip-coin

```rant
import: [[Programs#^flip-coin]]

[$flip-coin-with-values] {
    [flip-coin: Heads; Tails]
}
```
^flip-coin-with-values

```rant
import: [[Programs#^flip-coin-with-values]]

"Flipping a coin... "[flip-coin-with-values]!
```

As you can see, nested imports are supported, so you can import one (or multiple) programs in one block, and then import that block in another, and so on.

Installation

From within Obsidian

  1. Open Settings > Community plugins
  2. Make sure "Safe mode" is off
  3. In the community plugins browser, search for "Rant-Lang"
  4. Install & Enable
  5. Profit

Via BRAT

  1. Add lanice/obsidian-rant to the list of Beta plugins in the Obsidian42 - BRAT settings menu
  2. Enable the plugin in the Community plugins settings menu

Manually

  1. Download the latest release
  2. Extract the obsidian-rant folder from the zip to your vault <vault>/.obsidian/plugins/
  3. Reload Obsidian
  4. Enable the plugin in the Community plugins settings menu
You might also like...

A nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory

A nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory

This package is a nuxt 2 wrapper around derrickreimer/fathom-client to be able to use usefathom.com in all its glory. Thanks to @derrickreimer for this framework agnostic library ❤️‍🔥.

Aug 18, 2022

A maybe slightly safer-ish wrapper around eval Function constructors

evalish A maybe slightly safer-ish wrapper around eval Function constructors Please maybe try something else first.. Please. evalish is a small helper

Sep 6, 2022

A jQuery plugin wrapper around Bootstrap Alerts, to create Notifications (Toasts)

A jQuery plugin wrapper around Bootstrap Alerts, to create Notifications (Toasts)

bootstrap-show-notification A jQuery plugin wrapper around Bootstrap 4 Alerts, to show them as toasts (also called notifications) dynamically from Jav

Aug 22, 2022

A wrapper around IPFS for speeding up the loading of web3 frontend applications.

ipfs-wrapper A wrapper around ipfs-core for speeding up the loading of web3 frontend applications. Used on Blogchain. Requirements NodeJS v14.5.0 or h

Sep 14, 2022

A maybe slightly safer-ish wrapper around eval Function constructors

evalish A maybe slightly safer-ish wrapper around eval Function constructors Please maybe try something else first.. Please. evalish is a small helper

Aug 21, 2022

An even simpler wrapper around native Fetch to strip boilerplate from your fetching code!

An even simpler wrapper around native Fetch to strip boilerplate from your fetching code!

Super lightweight (~450 bytes) wrapper to simplify native fetch calls using any HTTP method (existing or imagined). Features Fully typed/TypeScript su

Dec 28, 2022

⚡⚙️ Fast prototyping with template engines and integrated frontend tools. Vituum is a small wrapper around Vite.

⚡⚙️ Fast prototyping with template engines and integrated frontend tools. Vituum is a small wrapper around Vite.

⚡ ⚙️ Vituum Still in early development. Fast prototyping with template engines and integrated frontend tools ⚡ Vite integrated 🚀️ Fast prototyping 🛠

Jan 3, 2023

An Obsidian plugin to paste Excel tables as Markdown tables in Obsidian editor.

An Obsidian plugin to paste Excel tables as Markdown tables in Obsidian editor.

Obsidian Excel to Markdown Table An Obsidian plugin to paste Excel tables as Markdown tables in Obsidian editor. Demo You can paste the copied Excel d

Jan 4, 2023

Obsidian-dataview-table-filter-menu - Dynamically created filter menu for dataview tables in obsidian

Dataview table Filter Menu for Obsidian Dynamically created filter menu for data

Sep 24, 2022
Comments
  • Explicit whitespace is being ignored

    Explicit whitespace is being ignored

    Again, thank you so much for this plugin!!! I was experimenting going through the examples and I found out that explicit whitespace is being ignored in the output, I'm not sure if this is an obsidian limitation or what

    The example I'm following is string literals with the first example

    "    This text is indented"
    

    I'll make more issues as I test this out!

    opened by wychwitch 3
  • Syntax error when using dice roller table

    Syntax error when using dice roller table

    I'm not sure what's going on with this, it seems all right!

    Here's the code

    `dice: [[Name Dice Tables#^names]]`
    

    It's very simple I know hahaha.

    And attached is the console log!

    obsidian.md-1641699851624.log

    Let me know if there's anything else I need to do!

    opened by wychwitch 2
  • Support for modules

    Support for modules

    It would be nice to support Rant modules in Obsidian.

    One way of doing this would be to allow within a rant codeblock to "import" a block-reference to another rant block as module, similar to how inline embedding currently works.

    Since the Rant module syntax using require actually looks for a .rant file in the file system, it might be easier to just ignore the module part, and "embed" blocks within rant codeblocks directly. Then you would just define functions (instead of modules) that you can import and use in other rant blocks.

    enhancement 
    opened by lanice 1
  • Hinting with a backtick still displays the backtick

    Hinting with a backtick still displays the backtick

    Hello, another small formatting issue!

    When hinting with a `backtick, the whitespace is handled correctly, but the backtick is still present, which I don't believe is intended behavior? Example is here

    # Explicitly hint the function call so the compiler knows it prints something
    Your lucky number is `[rand:1;100].
    

    Thanks again!

    wontfix 
    opened by wychwitch 4
Releases(0.5.9)
Owner
Leander Neiss
Leander Neiss
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
VSCode extension for the rickroll-lang programming language (incomplete)

Rickroll-Lang VSCode Extension The Rick Roll programming language is a rickroll based, process oriented, dynamic, strong, esoteric programming languag

Siddhesh Zantye 6 Oct 10, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
qwik.wrong-lang.click website source code

Qwik App ⚡️ Qwik Docs Discord Qwik Github @QwikDev Vite Partytown Mitosis Builder.io Project Structure Inside of you project, you'll see the following

Wrong Lang 3 Oct 7, 2022
A plugin for Obsidian (https://obsidian.md) that adds a button to its search view for copying the Obsidian search URL.

Copy Search URL This plugin adds a button to Obsidian's search view. Clicking it will copy the Obsidian URL for the current search to the clipboard. T

Carlo Zottmann 6 Dec 26, 2022
DOM ViewModel - A thin, fast, dependency-free vdom view layer

domvm (DOM ViewModel) A thin, fast, dependency-free vdom view layer (MIT Licensed) Introduction domvm is a flexible, pure-js view layer for building h

null 604 Dec 8, 2022
Bitcoin thin client for iOS & Android. Built with React Native Google Colab

Run bluewallet-Google-Colab https://colab.research.google.com/drive/1OShIMVcFZ_khsUIBOIV1lzrqAGo1gfm_?usp=sharing Thin Bitcoin Wallet. Built with Reac

DE MINING 0 Feb 25, 2022
A thin, opinionated headless wiki with few features.

thinwiki A thin, opinionated headless wiki with few features. Git used as a backing store Markdown files with front matter used for pages index.md pag

Ava Chaney 2 Oct 13, 2022
A simple nodejs module which is wrapper around solc that allows you to compile Solidity code

Simple Solidity Compiler It's a simple nodejs module which is wrapper around solc that allows you to compile Solidity code and get the abi and bytecod

King Rayhan 4 Feb 21, 2022