This demo shows how the CodeExtractor utility works. Hover over any code block to see the "Open in JSFiddle" button.
This page configures CodeExtractor through an HTML comment:
<!-- CodeExtractor: {
"urlTemplate": "https://jsfiddle.net/api/post/library/pure/?code={code}",
"buttonText": "Open in JSFiddle"
} -->
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
// Calculate first 10 Fibonacci numbers
for (let i = 0; i < 10; i++) {
console.log(fibonacci(i));
}
.container {
display: flex;
flex-direction: column;
gap: 10px;
max-width: 800px;
margin: 0 auto;
}
.item {
padding: 20px;
background-color: #f0f0f0;
border-radius: 5px;
transition: all 0.3s ease;
}
.item:hover {
transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
You can also create a button to manually extract code from a specific element: