jerryc127 / hexo-theme-butterfly

🦋 A Hexo Theme: Butterfly
https://butterfly.js.org
Apache License 2.0
6.8k stars 1.24k forks source link

[Feature]: Rendering pseudocode in math blocks #1496

Closed thomas10011 closed 1 week ago

thomas10011 commented 1 month ago

想要的功能 | What feature do you want?

Thanks for creating this wonderful theme. I'd like to request for a new feature of pseudocode math block rendering.

Since most of markdown editors (e.g. typora, obisidian) have supported the pseudocode code block like below:

```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}
``` /* end of code block */

We could use pseudocode.js to render it into math block, the output of this code snippet should be like:

image

useful reference: https://zjuguoshuai.gitlab.io/2019/04/26/blog-pseudocode.html

jerryc127 commented 1 month ago

what is pseudocode ? mathjax ?

thomas10011 commented 1 month ago

From wiki: https://en.wikipedia.org/wiki/Pseudocode

In computer science, pseudocode is a description of the steps in an algorithm using a mix of conventions of programming languages (like assignment operator, conditional operator, loop) with informal, usually self-explanatory, notation of actions and conditions.

Basically it's used to describe algorithm in most academic papers and books, and it's supported by latex softwares. For instance, the pseudocode in the picture I sticked above described the quick sort alogrithm. But mathjax currently can't render the pseudocode.

github-actions[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

jerryc127 commented 1 week ago

目前没计划实现这个 应该使用的人不多