Diagon
v1.1.158

对角是一个交互式解释器。它将Markdown风格的表达转换为ASCII-ART表示。
它用C ++编写,并使用WebAssembly,HTML和CSS制作Web应用程序。我们还将公开一个命令行界面和JS库,用于个人和第三方工具。
https://arthursonzogni.com/diagon/
对角也可作为命令行工具使用。例如:
echo " 1+1/2 + sum(i,0,10) = 113/2 " | diagon Math
10
___
1 ╲ 113
1 + ─ + ╱ i = ───
2 ‾‾‾ 2
0 要使用它,您可以从源头进行编译,也可以使用Snapstore上发布的预编译的二进制文件:
sudo snap install diagon它也可作为NIX软件包提供:
nix run github:petertrotman/nixpkgs/Diagon#diagon(A pull request is open to have this merged into NixOS/nixpkgs here )
查看JS图书馆Diagonjs
npm i diagonjs import Diagon from "diagonjs" ; const diagon = await Diagon . init ( ) ;
diagon . translate . math ( "f(x) = 1 + x / (1 + x)" , { style : "Unicode" } ) ;
// x
// f(x) = 1 + ─────
// 1 + x 使对角易于在IDE内部使用。感谢贡献者:
输入:
f(x) = 1 + x / (1 + x)
输出(Unicode):
x
f(x) = 1 + ─────
1 + x
输入:
sqrt(1+sqrt(1+x/2))
输出(Unicode)
_____________
╱ _____
╱ ╱ x
╱ 1 + ╱ 1 + ─
╲╱ ╲╱ 2
输入:
f(x) = 1 + x^2 + x^3 + x^(1+1/2)
输出(Unicode):
⎛ 1⎞
⎜1 + ─⎟
2 3 ⎝ 2⎠
f(x) = 1 + x + x + x
输入:
sum(i^2,i=0,n) = n^3/2+n^2/2+n/6
输出(Unicode):
n
___ 3 2
╲ 2 n n n
╱ i = ── + ── + ─
‾‾‾ 2 2 6
i = 0
输入:
int(x^2/2 * dx ,0,1) = 1/6
输出(Unicode):
1
⌠ 2
⎮ x 1
⎮ ── ⋅ dx = ─
⌡ 2 6
0
输入:
[a;b] + [c;d] = [a+c; b+d]
输出(Unicode):
⎛a⎞ ⎛c⎞ ⎛a + c⎞
⎜ ⎟ + ⎜ ⎟ = ⎜ ⎟
⎝b⎠ ⎝d⎠ ⎝b + d⎠
输入:
[1,2;3,4] * [x;y] = [1*x+2*y; 3*x+4*y]
⎛1 2⎞ ⎛x⎞ ⎛1 ⋅ x + 2 ⋅ y⎞
⎜ ⎟ ⋅ ⎜ ⎟ = ⎜ ⎟
⎝3 4⎠ ⎝y⎠ ⎝3 ⋅ x + 4 ⋅ y⎠
输入
Alice -> Bob: Hello Bob!
Alice <- Bob: Hello Alice!
输出(Unicode)
┌─────┐ ┌───┐
│Alice│ │Bob│
└──┬──┘ └─┬─┘
│ │
│ Hello Bob! │
│───────────>│
│ │
│Hello Alice!│
│<───────────│
┌──┴──┐ ┌─┴─┐
│Alice│ │Bob│
└─────┘ └───┘
输入
Renderer -> Browser: BeginNavigation()
Browser -> Network: URLRequest()
Browser <- Network: URLResponse()
Renderer <- Browser: CommitNavigation()
Renderer -> Browser: DidCommitNavigation()
输出(Unicode)
┌────────┐ ┌───────┐ ┌───────┐
│Renderer│ │Browser│ │Network│
└───┬────┘ └───┬───┘ └───┬───┘
│ │ │
│ BeginNavigation() │ │
│────────────────────>│ │
│ │ │
│ │URLRequest() │
│ │────────────>│
│ │ │
│ │URLResponse()│
│ │<────────────│
│ │ │
│ CommitNavigation() │ │
│<────────────────────│ │
│ │ │
│DidCommitNavigation()│ │
│────────────────────>│ │
┌───┴────┐ ┌───┴───┐ ┌───┴───┐
│Renderer│ │Browser│ │Network│
└────────┘ └───────┘ └───────┘
输入
1) Renderer -> Browser: Message 1
2) Renderer <- Browser: Message 2
Renderer: 1<2
Browser: 2<1
输出(Unicode)
┌────────┐┌───────┐
│Renderer││Browser│
└───┬────┘└───┬───┘
│ │
│──┐ │
│Message 2│
│<────────│
│ │ │
│Message 1│
│ └─────>│
┌───┴────┐┌───┴───┐
│Renderer││Browser│
└────────┘└───────┘
输入
Linux
Android
Debian
Ubuntu
Lubuntu
Kubuntu
Xubuntu
Xubuntu
Mint
Centos
Fedora
输出(样式Unicode 1)
Linux
├─Android
├─Debian
│ ├─Ubuntu
│ │ ├─Lubuntu
│ │ ├─Kubuntu
│ │ ├─Xubuntu
│ │ └─Xubuntu
│ └─Mint
├─Centos
└─Fedora
输出(样式ASCII 2)
Linux
+--Android
+--Debian
| +--Ubuntu
| | +--Lubuntu
| | +--Kubuntu
| | +--Xubuntu
| | `--Xubuntu
| `--Mint
+--Centos
`--Fedora
输出(样式Unicode右上角)
───Linux─┬─Android
├─Debian─┬─Ubuntu─┬─Lubuntu
│ │ ├─Kubuntu
│ │ ├─Xubuntu
│ │ └─Xubuntu
│ └─Mint
├─Centos
└─Fedora
输出(样式Unicode右中心)
┌─Android
│ ┌─Lubuntu
│ ├─Kubuntu
├─Debian─┬─Ubuntu─┼─Xubuntu
───Linux─┤ │ └─Xubuntu
│ └─Mint
├─Centos
└─Fedora
输入
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, World!";
return 0;
}
输出
┌─┬────────────────────────────┐
│1│#include <iostream> │
│2│using namespace std; │
│3│ │
│4│int main() │
│5│{ │
│6│ cout << "Hello, World!";│
│7│ return 0; │
│8│} │
└─┴────────────────────────────┘
输入
Column 1,Column 2,Column 3
C++,Web,Assembly
Javascript,CSS,HTML
输出(样式Unicode)
┌──────────┬────────┬────────┐
│Column 1 │Column 2│Column 3│
├──────────┼────────┼────────┤
│C++ │Web │Assembly│
├──────────┼────────┼────────┤
│Javascript│CSS │HTML │
└──────────┴────────┴────────┘
输入
if -> "then A" -> end
if -> "then B" -> end
end -> loop -> if
输出(Unicode)
┌──────────┐
│ if │
└△─┬──────┬┘
│ │ ┌▽─────┐
│ │ │then A│
│ │ └┬─────┘
│┌▽─────┐│
││then B││
│└┬─────┘│
│┌▽──────▽─┐
││ end │
│└┬────────┘
┌┴─▽─┐
│loop│
└────┘
输入:
socks -> shoes
underwear -> shoes
underwear -> pants
pants -> shoes
pants -> belt
belt -> jacket
shirt -> belt
shirt -> tie
tie -> jacket
输出:
┌─────┐┌─────────┐┌─────┐
│socks││underwear││shirt│
└┬────┘└┬─┬──────┘└┬─┬──┘
│ │┌▽─────┐ │┌▽───────┐
│ ││pants │ ││tie │
│ │└┬──┬──┘ │└┬───────┘
┌▽──────▽─▽┐┌▽─────▽┐│
│shoes ││belt ││
└──────────┘└┬──────┘│
┌────────────▽───────▽┐
│jacket │
└─────────────────────┘
输入:
chrome -> content
chrome -> blink
chrome -> base
content -> blink
content -> net
content -> base
blink -> v8
blink -> CC
blink -> WTF
blink -> skia
blink -> base
blink -> net
weblayer -> content
weblayer -> chrome
weblayer -> base
net -> base
WTF -> base
输出
┌────────┐
│weblayer│
└┬─┬─┬───┘
│ │┌▽────────────────────────┐
│ ││chrome │
│ │└┬─────┬─────────────────┬┘
│┌▽─▽────┐│ │
││content││ │
│└┬─┬─┬──┘│ │
│ │ │┌▽───▽──────────────┐ │
│ │ ││blink │ │
│ │ │└┬──┬───┬─┬───┬───┬─┘ │
│ │┌▽─▽┐┌▽──┐│┌▽─┐┌▽─┐┌▽───┐│
│ ││net││WTF│││v8││CC││skia││
│ │└┬──┘└┬──┘│└──┘└──┘└────┘│
┌▽─▽─▽────▽───▽──────────────▽┐
│base │
└─────────────────────────────┘
输入:
random -> pool_urbg
random -> nonsecure_base
random -> seed_sequence
random -> distribution
nonsecure_base -> pool_urbg
nonsecure_base -> salted_seed_seq
seed_sequence -> pool_urbg
seed_sequence -> salted_seed_seq
seed_sequence -> seed_material
distribution -> strings
pool_urbg -> seed_material
salted_seed_seq -> seed_material
seed_material -> strings
输出:
┌───────────────────────────────┐
│random │
└┬─────────────┬─────────────┬─┬┘
┌▽───────────┐┌▽────────────┐│┌▽─────────────┐
│distribution││seed_sequence│││nonsecure_base│
└┬───────────┘└┬───┬───────┬┘│└┬┬────────────┘
│ │ ┌│───────│─│─│┘
│ ┌───────────┘ ││ │ │┌┘
│ │┌─────────────▽▽┐┌─────▽─▽▽┐
│ ││salted_seed_seq││pool_urbg│
│ │└┬──────────────┘└┬────────┘
│┌▽─▽────────────────▽┐
││seed_material │
│└┬───────────────────┘
┌▽─▽────┐
│strings│
└───────┘
输入:
if ("DO YOU UNDERSTAND FLOW CHARTS?")
"GOOD!";
else if ("OKAY, YOU SEE THE LINE LABELED 'YES'?") {
if ("... AND YOU CAN SEE THE ONES LABELED 'NO'?") {
"GOOD";
} else {
if ("BUT YOU JUST FOLLOWED THEM TWICE?")
noop;
else
noop;
"(THAT WASN'T A QUESTION)";
"SCREW IT"
}
} else {
if ("BUT YOU SEE THE ONES LABELED 'NO'?") {
return "WAIT, WHAT?";
} else {
"LISTEN.";
return "I HATE YOU";
}
}
"LET'S GO DRING";
"HEY, I SHOULD TRY INSTALLING FREEBSD!"
输出:
_________________
╱ ╲ ┌─────┐
╱ DO YOU UNDERSTAND ╲____________________________________________________│GOOD!│
╲ FLOW CHARTS? ╱yes └──┬──┘
╲_________________╱ │
│no │
_________▽_________ ______________________ │
╱ ╲ ╱ ╲ ┌────┐ │
╱ OKAY, YOU SEE THE ╲________________╱ ... AND YOU CAN SEE ╲___│GOOD│ │
╲ LINE LABELED 'YES'? ╱yes ╲ THE ONES LABELED 'NO'? ╱yes└──┬─┘ │
╲___________________╱ ╲______________________╱ │ │
│no │no │ │
________▽_________ _________▽__________ │ │
╱ ╲ ┌───────────┐ ╱ ╲ │ │
╱ BUT YOU SEE THE ╲___│WAIT, WHAT?│ ╱ BUT YOU JUST ╲___ │ │
╲ ONES LABELED 'NO'? ╱yes└───────────┘ ╲ FOLLOWED THEM TWICE? ╱yes│ │ │
╲__________________╱ ╲____________________╱ │ │ │
│no │no │ │ │
┌───▽───┐ │ │ │ │
│LISTEN.│ └───────┬───────┘ │ │
└───┬───┘ ┌──────▽─────┐ │ │
┌─────▽────┐ │(THAT WASN'T│ │ │
│I HATE YOU│ │A QUESTION) │ │ │
└──────────┘ └──────┬─────┘ │ │
┌────▽───┐ │ │
│SCREW IT│ │ │
└────┬───┘ │ │
└─────┬─────┘ │
│ │
└─────┬─────┘
┌───────▽──────┐
│LET'S GO DRING│
└───────┬──────┘
┌─────────▽─────────┐
│HEY, I SHOULD TRY │
│INSTALLING FREEBSD!│
└───────────────────┘
在发布部分中提供了使用多种格式的二进制文件。
这取决于cmake和Linux上的libboost-graph-dev:
sudo apt install make libboost-graph-dev cmake default-jdk ;
mkdir build ;
cd build ;
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
sudo make install 如果您安装了Docker,则存储库包括一个方便建筑物的Dockerfile:
docker build -t diagon .构建后,可以像二进制一样调用图像:
docker run diagon Math -- " f(x) = 1 + x / (1 + x) "
echo " f(x) = 1 + x / (1 + x) " | docker run -i diagon Math由于这些伟大的项目,该项目可能是可能的