UNPKG

@phoenix-plugin-registry/brackets-markdown-preview

Version:

Markdown live preview incl. detached window, code syntax highlighting, output themes, adaptive preview width, graphical checkboxes, activation on start...

44 lines 2.57 kB
<!--htmlhint spec-char-escape: false--> <!DOCTYPE html> <html style="<%= backgroundColor %>"> <head> <base href="<%= baseUrl %>"> <link rel="preload" href="<%= themeUrl %>" as="style"> <link rel="preload" href="<%= previewStyleUrl %>" as="style"> <link rel="preload" href="<%= highlightThemeUrl %>" as="style"> <link rel="stylesheet" href ="<%= themeUrl %>"> <link rel="stylesheet" href ="<%= previewStyleUrl %>"> <link rel="stylesheet" href="<%= highlightThemeUrl %>"> <meta name="generator" content="brackets-markdown-preview"> <meta name="origin" content="<%= documentName %>"> <meta name="description" content="Preview of the Markdown document '<%= documentName %>'"> <%= outputCharacterEncoding %> <title><%= documentName %></title> </head> <body class="markdown-body <%= adaptiveWidthStyle %>" style="<%= backgroundColor %>"> <%= bodyText %> <script> // Fix the broken internal anchor links (HTML Bookmarks) issue when a BASE element with a HREF attribute is specified // => Adds an event listener for click events if the BASE element is found and if it have a HREF. // => The function will only adapt the behavior for in-page anchors (e.g. <a href="#bookmark">jump to bookmark</a>) // => This solution is using a listener for ALL clicks instead of one for the bookmark anchor elements only. // Hence, the solution deals properly with dynamically "generated" (e.g. per script) bookmarks! var base = document.getElementsByTagName("base")[0]; if (base && base.getAttribute("href")) { document.addEventListener("click", function(event) { var element = event.target; var href = element.getAttribute("href"); if (element.tagName.toLowerCase() == "a" && href.indexOf("#") === 0) { // Always reset the location hash first. // In oder case, repeating a click on the same link will be ignored. document.location.hash = ""; document.location.hash = href; //window.console.log("Anchor link: " + href); // when setting the hash value manually, we must prevent the default behavior of the click event event.preventDefault(); } }); } </script> </body> </html>