
Markdown Test 2: Code Blocks and Syntax Highlighting
Markdown Test 2: Code Blocks and Syntax Highlighting
This test focuses on code blocks, syntax highlighting across various programming languages, and technical content formatting. We’ll test edge cases, special characters, and ensure our syntax highlighter handles everything gracefully.
Inline Code Variations
Inline code can appear in many contexts:
- Simple inline code:
const x = 42 - Multiple inline codes in one line:
let,const, andvarare JavaScript keywords - Code with operators:
x += 1,y *= 2,z !== false - File paths:
/usr/local/bin,C:\Windows\System32,~/Documents/code.rs - Commands:
npm install,cargo build --release,git push origin main - URLs in code:
https://api.example.com/v1/posts
Special characters in inline code: <div>, &, "quotes", 'apostrophes', ${}, `backticks`
Basic Code Blocks
Without Language Specification
This is a simple code block without syntax highlighting.
It preserves spacing and line breaks.
Special characters: < > & " ' ` $ { } [ ] ( )
Unicode: → ← ↑ ↓ λ ∑ ∏ ≠ ≤ ≥
With Language but No Highlighting
Plain text block with language specified as 'text'.
This won't have syntax highlighting but maintains formatting.
Useful for configuration files, logs, or output examples.
Programming Languages Showcase
Rust - Systems Programming
// Fast Fibonacci using matrix exponentiation and the golden ratio
use Mul;
// Using Binet's formula with the golden ratio
JavaScript/TypeScript - Modern Web Development
// Conway's Game of Life in TypeScript
;
// Create a glider pattern
;
;
"Generation 0:";
;
for ; i <= 5; i++
Python - Data Science & Scripting
# Mandelbrot set visualization using NumPy vectorization
"""Generate Mandelbrot set using vectorized operations."""
# Create coordinate arrays
=
=
, =
# Complex grid
= + 1j *
=
=
# Vectorized iteration
# Only compute for points not yet escaped
= <= 2
= **2 +
=
return
"""Calculate viewport coordinates for a zoom level."""
= 3.5 /
= 2.5 /
return
# Generate and display interesting regions
=
# ASCII art visualization
"""Convert Mandelbrot data to ASCII art."""
# Characters arranged roughly by visual density (approximate)
=
=
# Downsample for terminal display
, =
=
= # 2x width for aspect ratio
return
# Generate ASCII visualization
=
# Calculate some interesting properties
"""Estimate area of Mandelbrot set using Monte Carlo."""
# Random points in [-2, 0.5] x [-1.25, 1.25]
=
=
= + 1j *
=
=
= **2 +
&= <= 2
# Area = sampled area × fraction in set
return 2.5 * 2.5 * /
SQL - Database Queries
-- Recursive Common Table Expression: Finding cycles in a graph
-- and calculating PageRank-style importance scores
WITH RECURSIVE
-- Define our graph edges (who follows whom)
followers AS (
VALUES
('Alice', 'Bob'), ('Bob', 'Charlie'), ('Charlie', 'Alice'), -- Cycle!
('Alice', 'Diana'), ('Diana', 'Eve'), ('Eve', 'Frank'),
('Frank', 'Diana'), ('Bob', 'Eve'), ('Charlie', 'Frank')
),
-- Find all paths and detect cycles
paths AS (
-- Base case: start from each person
SELECT
follower AS start_node,
followed AS current_node,
ARRAY[follower, followed] AS path,
false AS has_cycle,
1 AS depth
FROM followers
UNION ALL
-- Recursive case: extend paths
SELECT
p.start_node,
f.followed AS current_node,
p.path || f.followed AS path,
f.followed = ANY(p.path) AS has_cycle, -- Cycle detection
p.depth + 1
FROM paths p
JOIN followers f ON p.current_node = f.follower
WHERE p.depth < 10 -- Prevent infinite recursion
AND NOT p.has_cycle -- Stop when cycle found
),
-- Calculate influence scores (similar to PageRank)
influence AS (
SELECT
person,
COUNT(DISTINCT follower) AS direct_followers,
COUNT(DISTINCT path.start_node) AS reach, -- Unique people who can reach them
MAX(path.depth) AS max_influence_distance,
ARRAY_AGG(DISTINCT path.start_node) FILTER (WHERE path.depth > 2) AS indirect_influence
FROM (
SELECT DISTINCT unnest(path) AS person FROM paths
) people
LEFT JOIN followers ON people.person = followers.followed
LEFT JOIN paths path ON people.person = path.current_node
GROUP BY person
),
-- Find strongly connected components (cycles)
cycles AS (
SELECT DISTINCT
ARRAY_TO_STRING(
ARRAY(SELECT unnest(path) ORDER BY unnest),
' → '
) || ' → ' || path[1] AS cycle_visualization,
path
FROM paths
WHERE has_cycle
AND current_node = start_node -- Complete cycle
)
-- Final results
SELECT
'Influence Ranking:' AS analysis_type,
i.person AS entity,
i.direct_followers AS metric1,
i.reach AS metric2,
ROUND(
(i.direct_followers * 0.3 + i.reach * 0.7)::numeric,
2
) AS influence_score
FROM influence i
ORDER BY influence_score DESC
UNION ALL
SELECT
'Detected Cycles:' AS analysis_type,
cycle_visualization AS entity,
array_length(path, 1) - 1 AS metric1, -- Cycle length
NULL AS metric2,
NULL AS influence_score
FROM cycles
UNION ALL
-- Graph statistics using window functions
SELECT DISTINCT
'Graph Statistics:' AS analysis_type,
'Total Nodes: ' || COUNT(DISTINCT person) OVER AS entity,
COUNT(DISTINCT start_node || '→' || current_node) OVER AS metric1,
ROUND(AVG(depth) OVER::numeric, 2) AS metric2,
NULL AS influence_score
FROM paths, influence
LIMIT 1;
-- Bonus: Generate a Graphviz DOT representation
/*
SELECT 'digraph SocialNetwork {'
UNION ALL
SELECT DISTINCT ' ' || follower || ' -> ' || followed || ';'
FROM followers
UNION ALL
SELECT '}';
*/
Shell Scripting - Bash
#!/usr/bin/env bash
# A self-modifying quine that tracks its own execution count
# Initialize execution counter if this is first run
if ! ; then
fi
# Read current count
count=
# Update count in the script itself
if ; then
# macOS sed requires -i ''
else
# GNU sed
fi
# The quine part - print own source with decorations
| while ; do
# Syntax highlighting simulation
if ; then
elif ; then
else
fidone
# Fractal pattern generator using pure bash
# Clear area and draw fractal
for; do ; done
# One-liner magic: Generate prime numbers using bash
| while ; do
&& done |
# Visualize process tree as ASCII art
| | | | \
while ; do
width=
done
# The classic fork bomb (DON'T UNCOMMENT!)
# :(){ :|:& };:
# Execution count: will be added here
Edge Cases and Special Scenarios
Very Long Lines
# This is an extremely long line that should test how the syntax highlighter handles line wrapping, horizontal scrolling, and whether it maintains proper syntax highlighting across very long lines without breaking the layout or causing performance issues in the browser when rendering
Nested Language Blocks
Here’s HTML with embedded CSS and JavaScript:
Nested Languages Demo
Unicode in Code
# Unicode variable names and strings
"""Calculate sum (Σ) of numbers."""
= 3.14159
= 1.618
return * /
=
# Mathematical symbols
=
# Multi-language strings
=
Empty Code Blocks
# This block intentionally left almost empty
Performance Testing
Large Minified Code
// Minified code to test performance and readability
;
Conclusion
This test document demonstrates our syntax highlighter handles:
✅ Multiple programming languages with proper highlighting ✅ Special characters and Unicode ✅ Very long lines and large code blocks ✅ Nested language blocks ✅ Edge cases and empty blocks ✅ Performance with minified code
All code blocks render correctly with:
- Proper syntax highlighting
- Copy functionality
- Responsive design
- Dark/light theme support
Related Posts
Markdown Test 3: Advanced Features & Edge Cases
Exhaustive testing of advanced markdown features, complex nesting, edge cases, and stress tests for comprehensive parser validation including tables, footnotes, mathematical expressions, and extreme formatting combinations.
Markdown Test 1: Basic Formatting & Typography
A comprehensive test of basic markdown formatting including headers, emphasis, lists, links, images, and typography edge cases.