צודק. הנה שני הקבצים המלאים, כולל השינוי האחרון של א1. קובץ 1 — index.html מהדר שפת א
מהדר שפת א

קוד בשפת א

HTML שנוצר



    
Hosted & Compiled with HtmlRunner.com
קובץ 2 — compiler.js (function () { "use strict"; var generatedHTML = ""; var code = document.getElementById("code"); var compileButton = document.getElementById("compileButton"); var copyButton = document.getElementById("copyButton"); var output = document.getElementById("output"); var message = document.getElementById("message"); compileButton.onclick = function () { var source = code.value; output.textContent = ""; message.textContent = ""; message.className = ""; copyButton.style.display = "none"; if (source.trim() === "") { showError("לא הוזן קוד."); return; } try { var program = parseProgram(source); generatedHTML = createHTML(program); output.textContent = generatedHTML; copyButton.style.display = "inline-block"; showSuccess("התרגום הצליח."); } catch (error) { showError(error.message); } }; function parseProgram(source) { var lines = source.split(/\r?\n/); var result = []; var i = 0; while (i < lines.length) { var line = lines[i]; var trimmedLine = line.trim(); if (trimmedLine === "") { i++; continue; } if (trimmedLine.indexOf("*א1*") !== 0) { throw new Error( "פקודה לא תקינה בשורה " + (i + 1) + ": " + line ); } var value = trimmedLine .substring(4) .trim(); i++; if (value !== "") { result.push(value); continue; } var content = []; while (i < lines.length) { var nextLine = lines[i]; var nextTrimmed = nextLine.trim(); if ( nextTrimmed.indexOf("*א1*") === 0 ) { break; } content.push(nextLine); i++; } while ( content.length > 0 && content[0].trim() === "" ) { content.shift(); } while ( content.length > 0 && content[content.length - 1].trim() === "" ) { content.pop(); } if (content.length === 0) { throw new Error( "חסר תוכן אחרי *א1*" ); } value = content.join("\n"); result.push(value); } if (result.length === 0) { throw new Error( "לא נמצאו פקודות *א1*" ); } return result; } function createHTML(program) { var html = ""; html += "\n"; html += "\n"; html += "\n"; html += " \n"; html += " \n"; html += " אתר בשפת א\n"; html += " \n"; html += "\n"; html += "\n"; html += "
\n"; for (var i = 0; i < program.length; i++) { html += createContent(program[i]); } html += "
\n"; html += "\n"; html += ""; return html; } function createContent(value) { var text = value.trim(); if (isURL(text)) { if (isImageURL(text)) { return ( "
\n" + " \"\"\n" + "
\n" ); } if (isVideoURL(text)) { return ( "
\n" + " \n" + "
\n" ); } if (isAudioURL(text)) { return ( "
\n" + " \n" + "
\n" ); } if (isPDFURL(text)) { return ( "
\n" + " \n" + "
\n" ); } return ( "
\n" + " \n" + "
\n" ); } return ( "
" + escapeHTML(text) + "
\n" ); } function isURL(text) { return /^https?:\/\/\S+$/i.test(text); } function isImageURL(url) { return /\.(jpg|jpeg|png|gif|webp|svg|bmp|avif)(\?.*)?$/i.test(url); } function isVideoURL(url) { return /\.(mp4|webm|ogv|mov|m4v)(\?.*)?$/i.test(url); } function isAudioURL(url) { return /\.(mp3|wav|ogg|m4a|aac|flac)(\?.*)?$/i.test(url); } function isPDFURL(url) { return /\.pdf(\?.*)?$/i.test(url); } function escapeHTML(text) { return String(text) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function escapeAttribute(text) { return String(text) .replace(/&/g, "&") .replace(/"/g, """) .replace(//g, ">"); } copyButton.onclick = function () { if (!generatedHTML) { return; } if (navigator.clipboard) { navigator.clipboard .writeText(generatedHTML) .then(function () { showSuccess( "ה־HTML הועתק בהצלחה." ); }) .catch(function () { fallbackCopy(); }); } else { fallbackCopy(); } }; function fallbackCopy() { var box = document.createElement("textarea"); box.value = generatedHTML; box.style.position = "fixed"; box.style.left = "-9999px"; document.body.appendChild(box); box.select(); document.execCommand("copy"); document.body.removeChild(box); showSuccess( "ה־HTML הועתק בהצלחה." ); } function showSuccess(text) { message.textContent = text; message.className = "success"; } function showError(text) { message.textContent = text; message.className = "error"; } })();