ytliu74_obsidian-pseudocode/README.md

75 lines
2.9 KiB
Markdown
Raw Normal View History

2023-03-13 11:40:56 +00:00
# Obsidian-Pseudocode
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
This is a plugin for [Obsidian](https://obsidian.md/) that allows you to render LaTeX-style pseudocode inside a code block. The plugin is based on [pseudocode.js](https://github.com/SaswatPadhi/pseudocode.js), a JavaScript library that typesets pseudocode beautifully to HTML.
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
## Features
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
- 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 `\(...\)`.
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
### Future Features
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
- [ ] Syntax highlighting.
2023-03-19 03:53:35 +00:00
- [x] Auto-completion inside `pseudo` code block. (Release 1.1.0)
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
## Usage
2023-03-13 07:05:19 +00:00
2023-03-19 03:53:35 +00:00
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.
2023-03-13 07:05:19 +00:00
2023-03-24 12:05:41 +00:00
**Rocommend: use the command `Pseudocode: Insert a new pseudocode block` to start.**
2023-03-23 08:53:48 +00:00
2023-03-13 11:40:56 +00:00
Here is an example:
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
```
2023-03-19 03:53:35 +00:00
```pseudo
2023-03-13 11:40:56 +00:00
\begin{algorithm}
\caption{Quicksort}
\begin{algorithmic}
\PROCEDURE{Quicksort}{$A, p, r$}
\IF{$p < r$}
\STATE $q = $ \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 = A[r]$
\STATE $i = p - 1$
\FOR{$j = p$ \TO $r - 1$}
\IF{$A[j] < x$}
\STATE $i = i + 1$
\STATE exchange
$A[i]$ with $A[j]$
\ENDIF
\STATE exchange $A[i]$ with $A[r]$
\ENDFOR
\ENDPROCEDURE
\end{algorithmic}
\end{algorithm}
```
```
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
This will be rendered as:
2023-03-13 11:45:07 +00:00
<img src="assets/example.png" alt="example" width="70%">
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
## Installation
2023-03-13 07:05:19 +00:00
2023-03-30 05:54:18 +00:00
To install the plugin:
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](https://github.com/yaotian-liu/obsidian-pseudocode/releases/latest), to the folder you just created in step 1.
3. Open your Obsidian, and enable the plugin in "Community Plugins" setting page.
4. Enjoy.
2023-03-13 07:05:19 +00:00
2023-03-13 14:41:25 +00:00
~~Or just download it within Obsidian's community plugins.~~ (Pending...)
2023-03-13 07:05:19 +00:00
2023-03-19 06:04:58 +00:00
## Known Issues
2023-03-19 08:11:14 +00:00
- ~~The caption index will increase with each rendering.~~ (Release 1.1.3)
2023-03-19 06:04:58 +00:00
2023-03-13 11:40:56 +00:00
## Credits
2023-03-13 07:05:19 +00:00
2023-03-13 11:40:56 +00:00
This plugin is based on [pseudocode.js](https://github.com/SaswatPadhi/pseudocode.js), a JavaScript library that typesets pseudocode beautifully to HTML. Many thanks to the pseudocode.js team for their great work!