Skip to content

Commit febc870

Browse files
committed
Add Prism syntax highlighting.
Add prism to the plugins section of "book.json". Enable asm-x64 syntax highlighting by creating an alias. Make `asm-x64` an alias for `nasm`. Add "emojicode" to the ignore-list of prism. Enable prism syntax highlighting for smalltalk. Replace 'lang:"st"` with `lang:"smalltalk"` in affected import statements. Add "text" to the ignore-list of prism. Replace `lang:"c_cpp"`. Replace `lang:"c_cpp"` with `lang:"c"` and `lang:"cpp"` in the import statements.
1 parent 8578823 commit febc870

File tree

17 files changed

+94
-83
lines changed

17 files changed

+94
-83
lines changed

book.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"api-language-selector@https://github.com/algorithm-archivists/gitbook-plugin-api-language-selector.git",
1010
"include-codeblock",
1111
"ga",
12-
"bulk-redirect"
12+
"bulk-redirect",
13+
"prism",
14+
"-highlight"
1315
],
1416
"lunr": {
1517
"maxIndexSize": 1000000000
@@ -29,6 +31,15 @@
2931
"ga": {
3032
"token": "UA-118252470-1"
3133
},
34+
"prism": {
35+
"lang": {
36+
"asm-x64": "nasm"
37+
},
38+
"ignore": [
39+
"emojicode",
40+
"text"
41+
]
42+
},
3243
"api-language-selector": {
3344
"languages": [
3445
{

contents/bogo_sort/bogo_sort.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ In code, it looks something like this:
2020
{% sample lang="clj" %}
2121
[import:7-11, lang:"clojure"](code/clojure/bogo.clj)
2222
{% sample lang="c" %}
23-
[import:25-29, lang:"c_cpp"](code/c/bogo_sort.c)
23+
[import:25-29, lang:"c"](code/c/bogo_sort.c)
2424
{% sample lang="java" %}
2525
[import:2-6, lang:"java"](code/java/bogo.java)
2626
{% sample lang="js" %}
@@ -34,7 +34,7 @@ In code, it looks something like this:
3434
{% sample lang="lua" %}
3535
[import:1-22, lang="lua"](code/lua/bogosort.lua)
3636
{% sample lang="cpp" %}
37-
[import:33-38, lang:"c_cpp"](code/c++/bogosort.cpp)
37+
[import:33-38, lang:"cpp"](code/c++/bogosort.cpp)
3838
{% sample lang="rs" %}
3939
[import:16-20, lang:"rust"](code/rust/bogosort.rs)
4040
{% sample lang="swift" %}
@@ -54,7 +54,7 @@ In code, it looks something like this:
5454
{% sample lang="racket" %}
5555
[import:3-8, lang:"lisp"](code/racket/bogo_sort.rkt)
5656
{% sample lang="st" %}
57-
[import:2-6, lang:"st"](code/smalltalk/bogosort.st)
57+
[import:2-6, lang:"smalltalk"](code/smalltalk/bogosort.st)
5858
{% sample lang="bash" %}
5959
[import:38-45, lang:"bash"](code/bash/bogo_sort.bash)
6060
{% sample lang="asm-x64" %}
@@ -88,7 +88,7 @@ We are done here!
8888
{% sample lang="clj" %}
8989
[import, lang:"clojure"](code/clojure/bogo.clj)
9090
{% sample lang="c" %}
91-
[import, lang:"c_cpp"](code/c/bogo_sort.c)
91+
[import, lang:"c"](code/c/bogo_sort.c)
9292
{% sample lang="java" %}
9393
[import, lang:"java"](code/java/bogo.java)
9494
{% sample lang="js" %}
@@ -102,7 +102,7 @@ We are done here!
102102
{% sample lang="lua" %}
103103
[import, lang="lua"](code/lua/bogosort.lua)
104104
{% sample lang="cpp" %}
105-
[import, lang:"c_cpp"](code/c++/bogosort.cpp)
105+
[import, lang:"cpp"](code/c++/bogosort.cpp)
106106
{% sample lang="rs" %}
107107
[import, lang:"rust"](code/rust/bogosort.rs)
108108
{% sample lang="swift" %}
@@ -122,7 +122,7 @@ We are done here!
122122
{% sample lang="racket" %}
123123
[import, lang:"lisp"](code/racket/bogo_sort.rkt)
124124
{% sample lang="st" %}
125-
[import, lang:"st"](code/smalltalk/bogosort.st)
125+
[import, lang:"smalltalk"](code/smalltalk/bogosort.st)
126126
{% sample lang="bash" %}
127127
[import, lang:"bash"](code/bash/bogo_sort.bash)
128128
{% sample lang="asm-x64" %}

contents/bubble_sort/bubble_sort.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
1313
{% sample lang="cs" %}
1414
[import:9-27, lang:"csharp"](code/csharp/BubbleSort.cs)
1515
{% sample lang="c" %}
16-
[import:10-20, lang:"c_cpp"](code/c/bubble_sort.c)
16+
[import:10-20, lang:"c"](code/c/bubble_sort.c)
1717
{% sample lang="c8" %}
1818
[import:39-63, lang:"chip-8"](code/chip8/bubblesort.c8)
1919
{% sample lang="java" %}
@@ -31,7 +31,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
3131
{% sample lang="hs" %}
3232
[import, lang:"haskell"](code/haskell/bubbleSort.hs)
3333
{% sample lang="cpp" %}
34-
[import:13-23, lang:"c_cpp"](code/c++/bubblesort.cpp)
34+
[import:13-23, lang:"cpp"](code/c++/bubblesort.cpp)
3535
{% sample lang="rs" %}
3636
[import:6-16, lang:"rust"](code/rust/bubble_sort.rs)
3737
{% sample lang="d" %}
@@ -86,7 +86,7 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
8686
##### Program.cs
8787
[import, lang:"csharp"](code/csharp/Program.cs)
8888
{% sample lang="c" %}
89-
[import, lang:"c_cpp"](code/c/bubble_sort.c)
89+
[import, lang:"c"](code/c/bubble_sort.c)
9090
{% sample lang="c8" %}
9191
[import, lang:"chip-8"](code/chip8/bubblesort.c8)
9292
{% sample lang="java" %}
@@ -104,7 +104,7 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
104104
{% sample lang="hs" %}
105105
[import, lang:"haskell"](code/haskell/bubbleSort.hs)
106106
{% sample lang="cpp" %}
107-
[import, lang:"c_cpp"](code/c++/bubblesort.cpp)
107+
[import, lang:"cpp"](code/c++/bubblesort.cpp)
108108
{% sample lang="rs" %}
109109
[import, lang:"rust"](code/rust/bubble_sort.rs)
110110
{% sample lang="d" %}

contents/convolutions/convolutions.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ In code, this looks something like:
4141
{% sample lang="hs" %}
4242
[import:6-9, lang:"haskell"](code/haskell/convolution.hs)
4343
{% sample lang="c"%}
44-
[import:5-18, lang:"c_cpp"](code/c/convolutions.c)
44+
[import:5-18, lang:"c"](code/c/convolutions.c)
4545
{% sample lang="cpp"%}
46-
[import:68-88, lang:"c_cpp"](code/c++/convolutions.cpp)
46+
[import:68-88, lang:"cpp"](code/c++/convolutions.cpp)
4747
{% sample lang="python"%}
4848
[import:4-19, lang:"python"](code/python/conv.py)
4949
{% endmethod %}
@@ -91,9 +91,9 @@ Where the `.*` operator is an element-wise multiplication.
9191
[import:11-14, lang:"haskell"](code/haskell/convolution.hs)
9292
Where the `.*` operator is an element-wise multiplication.
9393
{% sample lang="c"%}
94-
[import:20-30, lang:"c_cpp"](code/c/convolutions.c)
94+
[import:20-30, lang:"c"](code/c/convolutions.c)
9595
{% sample lang="cpp"%}
96-
[import:90-105, lang:"c_cpp"](code/c++/convolutions.cpp)
96+
[import:90-105, lang:"cpp"](code/c++/convolutions.cpp)
9797
{% sample lang="python"%}
9898
[import:22-43, lang:"python"](code/python/conv.py)
9999
{% endmethod %}

contents/cooley_tukey/cooley_tukey.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ For some reason, though, putting code to this transformation really helped me fi
7272
{% sample lang="jl" %}
7373
[import:4-13, lang:"julia"](code/julia/fft.jl)
7474
{% sample lang="c" %}
75-
[import:8-19, lang:"c_cpp"](code/c/fft.c)
75+
[import:8-19, lang:"c"](code/c/fft.c)
7676
{% sample lang="clj" %}
7777
[import:15-30, lang:"clojure"](code/clojure/fft.clj)
7878
{% sample lang="cpp" %}
79-
[import:23-33, lang:"c_cpp"](code/c++/fft.cpp)
79+
[import:23-33, lang:"cpp"](code/c++/fft.cpp)
8080
{% sample lang="hs" %}
8181
[import:7-13, lang:"haskell"](code/haskell/fft.hs)
8282
{% sample lang="py" %}
@@ -119,11 +119,11 @@ In the end, the code looks like:
119119
{% sample lang="jl" %}
120120
[import:16-32, lang:"julia"](code/julia/fft.jl)
121121
{% sample lang="c" %}
122-
[import:20-39, lang:"c_cpp"](code/c/fft.c)
122+
[import:20-39, lang:"c"](code/c/fft.c)
123123
{% sample lang="clj" %}
124124
[import:31-58, lang:"clojure"](code/clojure/fft.clj)
125125
{% sample lang="cpp" %}
126-
[import:36-66, lang:"c_cpp"](code/c++/fft.cpp)
126+
[import:36-66, lang:"cpp"](code/c++/fft.cpp)
127127
{% sample lang="hs" %}
128128
[import:15-28, lang:"haskell"](code/haskell/fft.hs)
129129
{% sample lang="py" %}
@@ -225,11 +225,11 @@ Note: I implemented this in Julia because the code seems more straightforward in
225225
{% sample lang="jl" %}
226226
[import, lang:"julia"](code/julia/fft.jl)
227227
{% sample lang="c" %}
228-
[import, lang:"c_cpp"](code/c/fft.c)
228+
[import, lang:"c"](code/c/fft.c)
229229
{% sample lang="clj" %}
230230
[import, lang:"clojure"](code/clojure/fft.clj)
231231
{% sample lang="cpp" %}
232-
[import, lang:"c_cpp"](code/c++/fft.cpp)
232+
[import, lang:"cpp"](code/c++/fft.cpp)
233233
{% sample lang="hs" %}
234234
[import, lang:"haskell"](code/haskell/fft.hs)
235235
{% sample lang="py" %}

contents/forward_euler_method/forward_euler_method.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ Note that in this case, the velocity is directly given by the ODE and the accele
110110
{% sample lang="jl" %}
111111
[import, lang:"julia"](code/julia/euler.jl)
112112
{% sample lang="c" %}
113-
[import, lang:"c_cpp"](code/c/euler.c)
113+
[import, lang:"c"](code/c/euler.c)
114114
{% sample lang="cpp" %}
115-
[import, lang:"c_cpp"](code/c++/euler.cpp)
115+
[import, lang:"cpp"](code/c++/euler.cpp)
116116
{% sample lang="rs" %}
117117
[import, lang:"rust"](code/rust/euler.rs)
118118
{% sample lang="elm" %}

contents/gaussian_elimination/gaussian_elimination.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ $$
232232
$$
233233

234234
There are plenty of different strategies you could use to do this, and no one strategy is better than the rest.
235-
One method is to subtract a multiple of the top row from subsequent rows below it such that all values beneath the pivot value are zero.
235+
One method is to subtract a multiple of the top row from subsequent rows below it such that all values beneath the pivot value are zero.
236236
This process might be easier if you swap some rows around first and can be performed for each pivot.
237237

238238
After you get a row echelon matrix, the next step is to find the reduced row echelon form. In other words, we do the following:
@@ -312,8 +312,8 @@ In code, this process might look like this:
312312
{% sample lang="java" %}
313313
[import:14-30, lang:"java"](code/java/GaussianElimination.java)
314314
{% sample lang="c" %}
315-
[import:5-13, lang:"c_cpp"](code/c/gaussian_elimination.c)
316-
[import:19-34, lang:"c_cpp"](code/c/gaussian_elimination.c)
315+
[import:5-13, lang:"c"](code/c/gaussian_elimination.c)
316+
[import:19-34, lang:"c"](code/c/gaussian_elimination.c)
317317
{% sample lang="hs" %}
318318
[import:10-17, lang:"haskell"](code/haskell/gaussianElimination.hs)
319319
[import:44-46, lang:"haskell"](code/haskell/gaussianElimination.hs)
@@ -367,7 +367,7 @@ $$
367367
\left[
368368
\begin{array}{ccc|c}
369369
3 & -4 & 0 & 10 \\
370-
0 & \mathbf{\frac{10}{3}} & \mathbf{3} & \mathbf{\frac{2}{3}}
370+
0 & \mathbf{\frac{10}{3}} & \mathbf{3} & \mathbf{\frac{2}{3}}
371371
\\
372372
2 & 3 & 4 & 6
373373
\end{array}
@@ -383,7 +383,7 @@ Here is what it might look like in code:
383383
{% sample lang="java" %}
384384
[import:32-40, lang:"java"](code/java/GaussianElimination.java)
385385
{% sample lang="c" %}
386-
[import:36-41, lang:"c_cpp"](code/c/gaussian_elimination.c)
386+
[import:36-41, lang:"c"](code/c/gaussian_elimination.c)
387387
{% sample lang="hs" %}
388388
[import:19-33, lang:"haskell"](code/haskell/gaussianElimination.hs)
389389
[import:42-42, lang:"haskell"](code/haskell/gaussianElimination.hs)
@@ -402,7 +402,7 @@ When we put everything together, it looks like this:
402402
{% sample lang="jl" %}
403403
[import:1-45, lang:"julia"](code/julia/gaussian_elimination.jl)
404404
{% sample lang="c" %}
405-
[import:15-48, lang:"c_cpp"](code/c/gaussian_elimination.c)
405+
[import:15-48, lang:"c"](code/c/gaussian_elimination.c)
406406
{% sample lang="rs" %}
407407
[import:41-78, lang:"rust"](code/rust/gaussian_elimination.rs)
408408
{% sample lang="hs" %}
@@ -439,7 +439,7 @@ Here it is in code:
439439
{% sample lang="jl" %}
440440
[import:67-93, lang:"julia"](code/julia/gaussian_elimination.jl)
441441
{% sample lang="c" %}
442-
[import:64-82, lang:"c_cpp"](code/c/gaussian_elimination.c)
442+
[import:64-82, lang:"c"](code/c/gaussian_elimination.c)
443443
{% sample lang="rs" %}
444444
This code does not exist yet in rust, so here's Julia code (sorry for the inconvenience)
445445
[import:67-93, lang:"julia"](code/julia/gaussian_elimination.jl)
@@ -480,7 +480,7 @@ In code, it looks like this:
480480
{% sample lang="jl" %}
481481
[import:47-64, lang:"julia"](code/julia/gaussian_elimination.jl)
482482
{% sample lang="c" %}
483-
[import:50-62, lang:"c_cpp"](code/c/gaussian_elimination.c)
483+
[import:50-62, lang:"c"](code/c/gaussian_elimination.c)
484484
{% sample lang="rs" %}
485485
[import:79-94, lang:"rust"](code/rust/gaussian_elimination.rs)
486486
{% sample lang="hs" %}
@@ -495,7 +495,7 @@ In code, it looks like this:
495495

496496
## Visual Representation
497497

498-
We have thus far used Gaussian elimination as a method to solve a system of equations; however, there is often a much easier way to find a similar solution simply by plotting each row in our matrix.
498+
We have thus far used Gaussian elimination as a method to solve a system of equations; however, there is often a much easier way to find a similar solution simply by plotting each row in our matrix.
499499
For the case of 2 equations and 2 unknowns, we would plot the two lines corresponding to each equation and the $$(x, y)$$ location of their point of intersection would be the solution for $$x$$ and $$y$$.
500500
Similarly, for the case of 3 equations and 3 unknowns, we would plot 3 planes and the $$(x, y, z)$$ location of their point of intersection would be the solution for $$x$$, $$y$$, and $$z$$.
501501

@@ -543,7 +543,7 @@ Here's a video describing Gaussian elimination:
543543
{% sample lang="jl" %}
544544
[import, lang:"julia"](code/julia/gaussian_elimination.jl)
545545
{% sample lang="c" %}
546-
[import, lang:"c_cpp"](code/c/gaussian_elimination.c)
546+
[import, lang:"c"](code/c/gaussian_elimination.c)
547547
{% sample lang="rs" %}
548548
[import, lang:"rust"](code/rust/gaussian_elimination.rs)
549549
{% sample lang="hs" %}

contents/graham_scan/graham_scan.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ We can find whether a rotation is counter-clockwise with trigonometric functions
1717
{% sample lang="hs" %}
1818
[import:6-7, lang:"haskell"](code/haskell/grahamScan.hs)
1919
{% sample lang="c" %}
20-
[import:24-26, lang:"c_cpp"](code/c/graham.c)
20+
[import:24-26, lang:"c"](code/c/graham.c)
2121
{% sample lang="js" %}
2222
[import:36-38, lang:"javascript"](code/javascript/graham-scan.js)
2323
{% sample lang="py" %}
@@ -45,7 +45,7 @@ In the end, the code should look something like this:
4545
{% sample lang="hs" %}
4646
[import:9-18, lang:"haskell"](code/haskell/grahamScan.hs)
4747
{% sample lang="c" %}
48-
[import:65-95, lang:"c_cpp"](code/c/graham.c)
48+
[import:65-95, lang:"c"](code/c/graham.c)
4949
{% sample lang="js" %}
5050
[import:1-30, lang:"javascript"](code/javascript/graham-scan.js)
5151
{% sample lang="py" %}
@@ -68,7 +68,7 @@ In the end, the code should look something like this:
6868
{% sample lang="hs" %}
6969
[import, lang:"haskell"](code/haskell/grahamScan.hs)
7070
{% sample lang="c" %}
71-
[import, lang:"c_cpp"](code/c/graham.c)
71+
[import, lang:"c"](code/c/graham.c)
7272
{% sample lang="js" %}
7373
[import, lang:"javascript"](code/javascript/graham-scan.js)
7474
{% sample lang="py" %}

contents/huffman_encoding/huffman_encoding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Whether you use a stack or straight-up recursion also depends on the language, b
6767
{% sample lang="rs" %}
6868
[import, lang:"rust"](code/rust/huffman.rs)
6969
{% sample lang="c" %}
70-
[import, lang:"c_cpp"](code/c/huffman.c)
70+
[import, lang:"c"](code/c/huffman.c)
7171
{% sample lang="hs" %}
7272
[import, lang:"haskell"](code/haskell/huffman.hs)
7373
{% sample lang="cs" %}
@@ -78,7 +78,7 @@ Whether you use a stack or straight-up recursion also depends on the language, b
7878
{% sample lang="lua" %}
7979
[import, lang="lua"](code/lua/huffman.lua)
8080
{% sample lang="cpp" %}
81-
[import, lang:"c_cpp"](code/c++/huffman.cpp)
81+
[import, lang:"cpp"](code/c++/huffman.cpp)
8282
{% sample lang="clj" %}
8383
[import, lang:"clojure"](code/clojure/huffman.clj)
8484
{% sample lang="py" %}

contents/jarvis_march/jarvis_march.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ Since this algorithm, there have been many other algorithms that have advanced t
3333
{% sample lang="hs" %}
3434
[import, lang:"haskell"](code/haskell/jarvisMarch.hs)
3535
{% sample lang="c" %}
36-
[import, lang:"c_cpp"](code/c/jarvis_march.c)
36+
[import, lang:"c"](code/c/jarvis_march.c)
3737
{% sample lang="js" %}
3838
[import, lang:"javascript"](code/javascript/jarvis-march.js)
3939
{% sample lang="py" %}
4040
[import, lang:"python"](code/python/jarvisMarch.py)
4141
{% sample lang="cpp" %}
42-
[import, lang:"c_cpp"](code/c++/jarvis_march.cpp)
42+
[import, lang:"cpp"](code/c++/jarvis_march.cpp)
4343
{% sample lang="lisp" %}
4444
[import, lang:"lisp"](code/clisp/jarvis-march.lisp)
4545
{% sample lang="java" %}

contents/monte_carlo_integration/monte_carlo_integration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ each point is tested to see whether it's in the circle or not:
4242
{% sample lang="clj" %}
4343
[import:3-10, lang:"clojure"](code/clojure/monte_carlo.clj)
4444
{% sample lang="c" %}
45-
[import:7-9, lang:"c_cpp"](code/c/monte_carlo.c)
45+
[import:7-9, lang:"c"](code/c/monte_carlo.c)
4646
{% sample lang="cpp" %}
47-
[import:7-16, lang:"c_cpp"](code/c++/monte_carlo.cpp)
47+
[import:7-16, lang:"cpp"](code/c++/monte_carlo.cpp)
4848
{% sample lang="js" %}
4949
[import:2-6, lang:"javascript"](code/javascript/monte_carlo.js)
5050
{% sample lang="hs" %}
@@ -133,9 +133,9 @@ Feel free to submit your version via pull request, and thanks for reading!
133133
{% sample lang="clj" %}
134134
[import, lang:"clojure"](code/clojure/monte_carlo.clj)
135135
{% sample lang="c" %}
136-
[import, lang:"c_cpp"](code/c/monte_carlo.c)
136+
[import, lang:"c"](code/c/monte_carlo.c)
137137
{% sample lang="cpp" %}
138-
[import, lang:"c_cpp"](code/c++/monte_carlo.cpp)
138+
[import, lang:"cpp"](code/c++/monte_carlo.cpp)
139139
{% sample lang="js" %}
140140
[import, lang:"javascript"](code/javascript/monte_carlo.js)
141141
{% sample lang="hs" %}

contents/quantum_systems/quantum_systems.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ This ultimately looks like this:
230230
{% sample lang="hs" %}
231231
[import, lang:"haskell"](code/haskell/Energy.hs)
232232
{% sample lang="c" %}
233-
[import:29-, lang:"c_cpp"](code/c/energy.c)
233+
[import:29-, lang:"c"](code/c/energy.c)
234234
{% sample lang="cpp" %}
235-
[import:26-, lang:"c_cpp"](code/c++/energy.cpp)
235+
[import:26-, lang:"cpp"](code/c++/energy.cpp)
236236
{% sample lang="py" %}
237237
[import:4-17, lang:"python"](code/python/energy.py)
238238
{% endmethod %}

0 commit comments

Comments
 (0)