This document demonstrates the rendering of code blocks and syntax in PDF conversion.
Here is a simple Python function:
def calculate_sum(numbers):
"""Calculate the sum of a list of numbers."""
total = 0
for num in numbers:
total += num
return total
result = calculate_sum([1, 2, 3, 4, 5])
print(f"Sum: {result}")
Here is a JavaScript arrow function:
const fetchUserData = async (userId) => {
try {
const response = await fetch(`/api/users/${userId}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error('Error fetching user:', error);
return null;
}
};
Here is an HTML structure with CSS styling:
<div class="container">
<header class="header">
<h1>Welcome</h1>
</header>
<main class="content">
<p>Main content here</p>
</main>
</div>
Here is a sample SQL query:
SELECT u.id, u.name, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at > '2024-01-01'
GROUP BY u.id, u.name
ORDER BY order_count DESC
LIMIT 10;
Code blocks are properly formatted with monospace fonts, background highlighting, and proper indentation preservation.