1/** 2 * Elementor Markdown Handler 3 * Uses Elementor's JS hooks to render markdown in the editor and frontend. 4 */ 5(function ($) { 6 const MarkdownHandler = ($scope) => { 7 const $rawScript = $scope.find(".markdown-raw-content"); 8 const $target = $scope.find(".markdown-content-target"); 9 10 let md = ""; 11 12 if ($rawScript.length && $target.length) { 13 md = $rawScript.html(); 14 renderMarkdown(md, $target); 15 } else { 16 const $oldEl = $scope.find(".markdown-content"); 17 if ($oldEl.length) { 18 md = $oldEl.data("markdown"); 19 renderMarkdown(md, $oldEl); 20 } 21 } 22 }; 23 24 const renderMarkdown = (md, $container) => { 25 if (typeof marked !== "undefined" && md) { 26 try { 27 const htmlContent = marked.parse(md.trim()); 28 $container.html(htmlContent); 29 } catch (e) { 30 console.error("Markdown parsing failed:", e); 31 $container.html( 32 '<p style="color:red;">Error parsing markdown content.</p>', 33 ); 34 } 35 } else if (typeof marked === "undefined") { 36 console.warn("Marked.js library is not loaded."); 37 } 38 }; 39 40 $(window).on("elementor/frontend/init", function () { 41 elementorFrontend.hooks.addAction( 42 "frontend/element_ready/markdown-widget.default", 43 MarkdownHandler, 44 ); 45 }); 46})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.