No description
Find a file
2023-04-24 15:32:30 +08:00
.github/workflows bug: fix a wrong expression 2023-03-25 23:06:45 +08:00
assets doc: Update README 2023-04-24 15:32:30 +08:00
.editorconfig chore: add auto-release workflow 2023-03-19 11:51:32 +08:00
.eslintignore Initial commit 2023-03-13 15:05:19 +08:00
.eslintrc Initial commit 2023-03-13 15:05:19 +08:00
.gitignore chore: inline online fonts with base64 2023-03-16 01:10:59 +08:00
.npmrc Initial commit 2023-03-13 15:05:19 +08:00
esbuild.config.mjs Initial commit 2023-03-13 15:05:19 +08:00
extract_katexcss.py chore: inline online fonts with base64 2023-03-16 01:10:59 +08:00
katex.min.css chore: inline online fonts with base64 2023-03-16 01:10:59 +08:00
LICENSE Create LICENSE 2023-03-13 20:12:41 +08:00
main.ts style: Make error msg look better 2023-04-16 13:09:35 +08:00
manifest.json new release 1.1.8 2023-04-16 13:11:30 +08:00
package-lock.json new release 1.1.7 2023-04-16 12:17:42 +08:00
package.json new release 1.1.8 2023-04-16 13:11:30 +08:00
pseudocode.d.ts feat: add main function of render 2023-03-13 19:40:20 +08:00
README.md doc: Update README 2023-04-24 15:32:30 +08:00
styles.css style: Make error msg look better 2023-04-16 13:09:35 +08:00
tsconfig.json Initial commit 2023-03-13 15:05:19 +08:00
version-bump.mjs Initial commit 2023-03-13 15:05:19 +08:00
versions.json new release 1.1.8 2023-04-16 13:11:30 +08:00

Obsidian-Pseudocode

This is a plugin for Obsidian that allows you to render LaTeX-style pseudocode inside a code block. The plugin is based on pseudocode.js, a JavaScript library that typesets pseudocode beautifully to HTML.

Features

  • Intuitive grammar: The plugin takes a LaTeX-style input that supports the algorithmic constructs from LaTeX's algorithm packages. With or without LaTeX experience, a user should find the grammar fairly intuitive.
  • Print quality: The HTML output produced by the plugin is (almost) identical with the pretty algorithms printed on publications that are typeset by LaTeX.
  • Math formula support: Inserting math formulas in the pseudocode is as easy as LaTeX. Just enclose math expression in $...$ or \(...\).

Future Features

  • Generate a LaTeX file that can be compiled, including any required additional macros.
  • Syntax highlighting.
  • Auto-completion inside pseudo code block. (Release 1.1.0)

Usage

To use the plugin, simply create a code block in your Obsidian note and add your pseudocode inside it. Then, add the language specifier pseudo (short for "pseudocode") to the code block. The plugin will automatically render the pseudocode as LaTeX.

Rocommend: use the command Pseudocode: Insert a new pseudocode block to start.

Here is an example:

    ```pseudo
    \begin{algorithm}
    \caption{Quicksort}
    \begin{algorithmic}
      \Procedure{Quicksort}{$A, p, r$}
        \If{$p < r$}
          \State $q \gets $ \Call{Partition}{$A, p, r$}
          \State \Call{Quicksort}{$A, p, q - 1$}
          \State \Call{Quicksort}{$A, q + 1, r$}
        \EndIf
      \EndProcedure
      \Procedure{Partition}{$A, p, r$}
        \State $x \gets A[r]$
        \State $i \gets p - 1$
        \For{$j \gets p$ \To $r - 1$}
          \If{$A[j] < x$}
            \State $i \gets i + 1$
            \State exchange
            $A[i]$ with $A[j]$
          \EndIf
        \State exchange $A[i]$ with $A[r]$
        \EndFor
      \EndProcedure
      \end{algorithmic}
    \end{algorithm}
    ```

This will be rendered as:

example

Installation

Install from the Community Plugins in Obsidian.

🎉 The Pseudocode plugin is now available in the Community Plugins section of Obsidian. To install it, simply search for Pseudocode and click on the installation button.

Use BRAT

  1. Install Obsidian-42 BRAT from the Community Plugins in Obsidian.
  2. Open the command palette and run the command BRAT: Add a beta plugin for testing. Input this repo's URL https://github.com/Yaotian-Liu/obsidian-pseudocode.
  3. Click on Add Plugin -- wait a few seconds and BRAT will tell you what is going on.
  4. After BRAT confirms the installation, in Settings go to the Community plugins tab.
  5. Refresh the list, find Pseudocode and enable it.

Manual install

  1. Create a folder named pseudocode-in-obs in your Obsidian vault plugin folder (which is {Your Vault}/.obsidian/plugins).
  2. Download main.js, manifest.json and styles.css from the releases page, to the folder you just created in step 1.
  3. Open your Obsidian, and enable the plugin in "Community Plugins" setting page.
  4. Enjoy.

Credits

This plugin is based on pseudocode.js, a JavaScript library that typesets pseudocode beautifully to HTML. Many thanks to the pseudocode.js team for their great work!