This article serves as a test page to demonstrate and verify the rendering of code block syntax and LaTeX mathematical equations on this blog.
1. Code Syntax Highlighting Test
Below is a Python snippet implementing the classic Quick Sort algorithm. This tests our clean bw (black-and-white) syntax highlighting theme, custom monospace fonts, and the hover-activated dynamic code clipboard copy button.
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
# Test the function
numbers = [3, 6, 8, 10, 1, 2, 1]
print("Sorted array:", quicksort(numbers))
2. Mathematical Formula Test
This section verifies that LaTeX equations are parsed and rendered beautifully using KaTeX.
Inline Formula
You can write mathematical equations inline, such as the famous mass-energy equivalence formula $E = mc^2$, or the definition of the Euler’s identity: $e^{i\pi} + 1 = 0$.
Block Formula
For larger and more complex equations, you can display them as a centered block:
$$ f(x) = \int_{-\infty}^{\infty} \hat{f}(\xi) e^{2 \pi i \xi x} d\xi $$
Or a matrix definition:
$$ \mathbf{A} = \begin{pmatrix} a & b \\ c & d \end{pmatrix} $$
Both inline and block formulas should render with crisp vector graphics.