Getting Started

Run your first code samples with Elide

Before you start

You'll need an installed copy of Elide. Follow the Installation guide to obtain a copy of Elide.

Running some code

Elide can accept a file to run in any supported language. Best attempts are made to detect the primary language via the source file's extension (.js will load a JS VM, etc.).

1. Let's run a snippet of JavaScript
js
// hello.js
console.log("Hello!");
bash
 elide hello.js
shell
Hello!
2. Now let's do the same thing, but with TypeScript
ts
// hello.ts
let hello: string = "Hello!";
console.log(hello);
bash
 elide hello.ts
shell
Hello!

See Also

'; } return '' + '
' + '' + '' + '' + '
' + '
' + displayTitle + '
' + '
' + item.category + ' / ' + item.section + '
' + preview + '
' + '
' + '
'; }).join(''); selectedIndex = -1; showDropdown(); } // Input handler with debounce let debounceTimer; searchInput.addEventListener('input', (e) => { clearTimeout(debounceTimer); debounceTimer = setTimeout(() => { performSearch(e.target.value.trim()); }, 150); }); // Keyboard navigation searchInput.addEventListener('keydown', (e) => { const items = searchResults.querySelectorAll('.search-result-item'); const itemCount = items.length; if (e.key === 'ArrowDown') { e.preventDefault(); selectedIndex = Math.min(selectedIndex + 1, itemCount - 1); updateSelection(); } else if (e.key === 'ArrowUp') { e.preventDefault(); selectedIndex = Math.max(selectedIndex - 1, -1); updateSelection(); } else if (e.key === 'Enter' && selectedIndex >= 0) { e.preventDefault(); const selectedItem = items[selectedIndex]; if (selectedItem) { window.location.href = selectedItem.getAttribute('href'); } } else if (e.key === 'Escape') { hideDropdown(); searchInput.blur(); } }); // Hide on blur (with delay for click handling) searchInput.addEventListener('blur', () => { setTimeout(hideDropdown, 200); }); // Show on focus if there's a query searchInput.addEventListener('focus', () => { if (searchInput.value.trim().length >= 2) { performSearch(searchInput.value.trim()); } }); })(); // Table of Contents scroll tracking with pink/purple highlighting (function() { const tocLinks = document.querySelectorAll('.toc-link'); if (tocLinks.length === 0) return; // Purple/pink color const activeColor = 'rgb(168, 85, 247)'; const activeBorderWidth = '3px'; const inactiveBorderWidth = '2px'; const isRTL = document.documentElement.dir === 'rtl'; const borderColorProp = isRTL ? 'borderRightColor' : 'borderLeftColor'; const borderWidthProp = isRTL ? 'borderRightWidth' : 'borderLeftWidth'; // Get all headings that have IDs const headings = Array.from(document.querySelectorAll('h2[id], h3[id]')); const tocSidebar = document.getElementById('toc-sidebar'); // Function to scroll TOC to show active item function scrollTocToActiveItem(activeLink) { if (!tocSidebar || !activeLink) return; const sidebarRect = tocSidebar.getBoundingClientRect(); const linkRect = activeLink.getBoundingClientRect(); // Check if link is outside visible area const isAboveView = linkRect.top < sidebarRect.top; const isBelowView = linkRect.bottom > sidebarRect.bottom; if (isAboveView || isBelowView) { // Calculate position to center the active item in the sidebar const linkOffsetInSidebar = activeLink.offsetTop; const sidebarHeight = tocSidebar.clientHeight; const linkHeight = activeLink.offsetHeight; // Scroll to center the active item (with some padding) const scrollTo = linkOffsetInSidebar - (sidebarHeight / 2) + (linkHeight / 2); tocSidebar.scrollTo({ top: Math.max(0, scrollTo), behavior: 'smooth' }); } } // Track current active heading let currentActiveId = headings[0]?.id || null; // Function to set active TOC link function setActiveTocLink(headingId) { if (!headingId) return; currentActiveId = headingId; let activeLinkElement = null; tocLinks.forEach(link => { const tocId = link.getAttribute('data-toc-id'); const isActive = tocId === headingId; if (isActive) { activeLinkElement = link; link.classList.remove('text-muted-foreground', 'border-transparent'); link.classList.add('text-primary'); link.style[borderColorProp] = activeColor; link.style[borderWidthProp] = activeBorderWidth; link.style.color = activeColor; } else { link.classList.remove('text-primary'); link.classList.add('text-muted-foreground'); link.style[borderColorProp] = 'transparent'; link.style[borderWidthProp] = inactiveBorderWidth; link.style.color = ''; } }); if (activeLinkElement) { scrollTocToActiveItem(activeLinkElement); } } // Use IntersectionObserver for reliable heading detection const observerOptions = { // Negative top margin to trigger when heading is below navbar rootMargin: '-20% 0px -70% 0px', threshold: 0 }; const headingObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { setActiveTocLink(entry.target.id); } }); }, observerOptions); // Observe all headings headings.forEach(heading => headingObserver.observe(heading)); // Activate first heading when scrolled above all headings function checkScrollTop() { if (headings.length === 0) return; var firstRect = headings[0].getBoundingClientRect(); if (firstRect.top > window.innerHeight * 0.3) { setActiveTocLink(headings[0].id); } } // Legacy function for compatibility function updateActiveTocLink() { setActiveTocLink(currentActiveId); } // Add hover effects tocLinks.forEach(link => { // Hover in link.addEventListener('mouseenter', () => { link.style[borderColorProp] = activeColor; link.style[borderWidthProp] = activeBorderWidth; link.style.color = activeColor; }); // Hover out - restore state link.addEventListener('mouseleave', () => { const tocId = link.getAttribute('data-toc-id'); const scrollPosition = window.scrollY + 150; let currentHeading = headings[0]; for (let i = headings.length - 1; i >= 0; i--) { if (headings[i].offsetTop <= scrollPosition) { currentHeading = headings[i]; break; } } const isActive = currentHeading && currentHeading.id === tocId; if (!isActive) { link.style[borderColorProp] = 'transparent'; link.style[borderWidthProp] = inactiveBorderWidth; link.style.color = ''; } }); // Click handler for smooth scroll link.addEventListener('click', (e) => { e.preventDefault(); const targetId = link.getAttribute('data-toc-id'); const targetElement = document.getElementById(targetId); if (targetElement) { // Use scrollIntoView which respects CSS scroll-padding-top automatically targetElement.scrollIntoView({ behavior: 'smooth', block: 'start' }); // Scroll TOC to show clicked item scrollTocToActiveItem(link); // Update immediately setTimeout(updateActiveTocLink, 100); } }); }); // Update on scroll (throttled for performance) let ticking = false; window.addEventListener('scroll', () => { if (!ticking) { window.requestAnimationFrame(() => { checkScrollTop(); updateActiveTocLink(); ticking = false; }); ticking = true; } }); // Initial update checkScrollTop(); updateActiveTocLink(); })();