מהדר שפת א — א1

קוד שפת א

HTML שנוצר

עדיין לא נוצר HTML.
\n" + ""; document .getElementById("result") .textContent = fullHTML; } catch (error) { showError( error.message ); } } function makeHTML(value) { var text = value.trim(); if ( /^https?:\/\//i.test(text) ) { return makeURLHTML(text); } return ( "
" + escapeHTML(text) + "
\n" ); } function makeURLHTML(url) { var lower = url.toLowerCase(); /* YouTube */ if ( lower.indexOf("youtube.com") !== -1 || lower.indexOf("youtu.be") !== -1 ) { var youtubeID = getYouTubeID(url); if (youtubeID) { return ( "
\n" + " \n" + "
\n" ); } } /* Vimeo */ if ( lower.indexOf("vimeo.com") !== -1 ) { var vimeoID = getVimeoID(url); if (vimeoID) { return ( "
\n" + " \n" + "
\n" ); } } /* תמונה */ if ( /\.(jpg|jpeg|png|gif|webp|svg)(\?.*)?$/i .test(url) ) { return ( "
\n" + " \n" + "
\n" ); } /* וידאו */ if ( /\.(mp4|webm|ogg|mov)(\?.*)?$/i .test(url) ) { return ( "
\n" + " \n" + "
\n" ); } /* אודיו */ if ( /\.(mp3|wav|m4a|aac|flac)(\?.*)?$/i .test(url) ) { return ( "
\n" + " \n" + "
\n" ); } /* קישור רגיל */ return ( "
\n" + " " + escapeHTML(url) + "\n" + "
\n" ); } function getYouTubeID(url) { try { var parsed = new URL(url); var host = parsed.hostname.toLowerCase(); if ( host.indexOf("youtu.be") !== -1 ) { return parsed.pathname .replace(/^\/+/, "") .split("/")[0]; } if ( host.indexOf("youtube.com") !== -1 ) { var videoID = parsed.searchParams.get("v"); if (videoID) { return videoID; } var shorts = parsed.pathname.match( /\/shorts\/([^/?]+)/ ); if (shorts) { return shorts[1]; } var embed = parsed.pathname.match( /\/embed\/([^/?]+)/ ); if (embed) { return embed[1]; } } } catch (error) { return null; } return null; } function getVimeoID(url) { var match = url.match( /vimeo\.com\/(?:video\/)?(\d+)/i ); if (match) { return match[1]; } return null; } function escapeHTML(text) { return String(text) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function escapeAttribute(text) { return escapeHTML(text); } function showError(message) { document .getElementById("result") .innerHTML = "
" + escapeHTML(message) + "
"; } function copyHTML() { var text = document .getElementById("result") .textContent; if ( text.trim() === "" ) { return; } if ( navigator.clipboard && navigator.clipboard.writeText ) { navigator.clipboard .writeText(text) .then(function () { alert("ה-HTML הועתק"); }) .catch(function () { fallbackCopy(text); }); } else { fallbackCopy(text); } } function fallbackCopy(text) { var textarea = document.createElement("textarea"); textarea.value = text; textarea.style.position = "fixed"; textarea.style.left = "-9999px"; document.body.appendChild( textarea ); textarea.focus(); textarea.select(); try { document.execCommand("copy"); alert("ה-HTML הועתק"); } catch (error) { alert("ההעתקה נכשלה"); } textarea.remove(); }