| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d248993 commit 73874b1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,29 +106,39 @@ export const panelsViewer = { | |||
| 106 | 106 | const e = new XMLHttpRequest(); | |
| 107 | 107 | // @todo: look deeper into how we can refactor this particular code block | |
| 108 | 108 | /* eslint-disable */ | |
| 109 | - e.onload = (function(i, panels, patternData, iframeRequest) { | ||
| 110 | - return function() { | ||
| 109 | + e.onload = (function (i, panels, patternData, iframeRequest) { | ||
| 110 | + return function () { | ||
| 111 | + | ||
| 112 | + // since non-existant files (such as .scss from plugin-tab) still return a 200, we need to instead inspect the contents | ||
| 113 | + // we look for responseText that starts with the doctype | ||
| 114 | + let rText = this.responseText | ||
| 115 | + if (rText.startsWith('<!DOCTYPE html>')) { | ||
| 116 | + rText = '' | ||
| 117 | + } | ||
| 118 | + | ||
| 111 | 119 | // use pretty to format HTML | |
| 112 | 120 | if (panels[i].name === 'HTML') { | |
| 113 | - templateFormatted = pretty(this.responseText, { ocd: true }); | ||
| 121 | + templateFormatted = pretty(rText, { ocd: true }); | ||
| 114 | 122 | } else { | |
| 115 | - templateFormatted = this.responseText; | ||
| 123 | + templateFormatted = rText; | ||
| 116 | 124 | } | |
| 117 | 125 | ||
| 118 | 126 | const templateHighlighted = Prism.highlight( | |
| 119 | 127 | templateFormatted, | |
| 120 | 128 | Prism.languages[panels[i].name.toLowerCase()] || | |
| 121 | - Prism.languages['markup'] | ||
| 129 | + Prism.languages['markup'] | ||
| 122 | 130 | // Prism.languages[panels[i].name.toLowerCase()], | |
| 123 | 131 | ); | |
| 124 | 132 | ||
| 125 | - const codeTemplate = (code, language) => | ||
| 126 | - html` | ||
| 133 | + if (templateHighlighted.) | ||
| 134 | + | ||
| 135 | + const codeTemplate = (code, language) => | ||
| 136 | + html` | ||
| 127 | 137 | <pre | |
| 128 | 138 | class="language-markup" | |
| 129 | 139 | ><code id="pl-code-fill-${language}" class="language-${language}">${unsafeHTML( | |
| 130 | - code | ||
| 131 | - )}</code></pre> | ||
| 140 | + code | ||
| 141 | + )}</code></pre> | ||
| 132 | 142 | `; | |
| 133 | 143 | ||
| 134 | 144 | const result = document.createDocumentFragment(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments