Update inde.html
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CSS Preprocessor Example</title> <style id="processed-css"></style></head><body> <div class="container"> <h1>Hello, World!</h1> <p>This is a simple example of using a CSS preprocessor.</p> </div>
<script> // Define variables const variables = { primaryColor: '#007bff', secondaryColor: '#6c757d', };
// Define mixins const mixins = { flexCenter: ` display: flex; justify-content: center; align-items: center; `, };
// Parse and process CSS function preprocessCSS(css) { // Resolve variables for (const [key, value] of Object.entries(variables)) { css = css.replace(new RegExp(`\\$${key}`, 'g'), value); }
// Expand mixins for (const [key, value] of Object.entries(mixins)) { css = css.replace(new RegExp(`@mixin ${key}`, 'g'), value); }
return css; }
// Example usage const inputCSS = ` body { background-color: $primaryColor; color: $secondaryColor; @mixin flexCenter; } `;
const processedCSS = preprocessCSS(inputCSS); document.getElementById('processed-css').innerText = processedCSS; </script></body></html>inde.html+59