שפת א 1.0

תצוגת האתר
קוד HTML מלא
שפת א
`; const htmlCode = document.getElementById("htmlCode"); const aCode = document.getElementById("aCode"); const preview = document.getElementById("preview"); const errorMessage = document.getElementById("errorMessage"); const copyMessage = document.getElementById("copyMessage"); htmlCode.value = initialHTML; function showPreview() { preview.srcdoc = htmlCode.value; } function htmlToA(html) { const parser = new DOMParser(); const doc = parser.parseFromString(html, "text/html"); const heading = doc.querySelector("h1"); if (heading) { return "א1 " + heading.textContent.trim(); } return ""; } function compileA(code) { const lines = code .split("\n") .map(line => line.trim()) .filter(line => line !== ""); let content = ""; for (const line of lines) { if (line.startsWith("א1 ")) { const text = line.substring(3).trim(); content += `

${escapeHTML(text)}

`; } else { throw new Error("פקודה לא מוכרת: " + line); } } return ` האתר שלי ${content} `; } function approveA() { errorMessage.textContent = ""; try { const newHTML = compileA(aCode.value); htmlCode.value = newHTML; showPreview(); } catch (error) { errorMessage.textContent = error.message; } } async function copyHTML() { const text = htmlCode.value; try { await navigator.clipboard.writeText(text); copyMessage.textContent = "הקוד הועתק"; } catch (error) { htmlCode.focus(); htmlCode.select(); document.execCommand("copy"); copyMessage.textContent = "הקוד הועתק"; } setTimeout(() => { copyMessage.textContent = ""; }, 2000); } function escapeHTML(text) { return text .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } aCode.value = htmlToA(initialHTML); showPreview();