Cimbali / markdown-viewer

Markdown (.md) file viewer WebExtension for your browser.
Other
165 stars 28 forks source link

Cannot render <html> <head> <title> content #64

Closed bouygues closed 4 years ago

bouygues commented 4 years ago

When " " appears in content of a Markdown file, it will not be renderred correctly -- cannot display at all. Sample as following: </p> <pre><code># Title: my tile ## Sub title: my sub title This is the content, which includes <html><head><title> tags. But you cannot see me here. Cause the extension cannot render any content after <html> tag in previous line. <br> - This is the content, which includes <html><head><title> tags. - But you cannot see me here. Cause the extension cannot render any content after <html> tag in previous line. </code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/bouygues"><img src="https://avatars.githubusercontent.com/u/3401043?v=4" />bouygues</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>OMG, I cannot type the markdown sample code here. So I attach it as a txt file. <a href="https://github.com/KeithLRobertson/markdown-viewer/files/3899778/test.md.txt">test.md.txt</a></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Cimbali"><img src="https://avatars.githubusercontent.com/u/6126377?v=4" />Cimbali</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>Since html tags are allowed in markdown, if you want tags that appear in the text they should be escaped in the source. </p> <p>Does using either <code>\<html\></code> or <code>&lt;html&gt;</code> work? </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/Cimbali"><img src="https://avatars.githubusercontent.com/u/6126377?v=4" />Cimbali</a> commented <strong> 4 years ago</strong> </div> <div class="markdown-body"> <p>So I had a quick look at this:</p> <ul> <li>Using <code>\<html\>\<head\>\<title\></code> seems to work.</li> <li>The <code><head></code> tag is left as-is in the markdown output, I suppose firefox interprets it generously (that is, ignoring the missing <code>/</code>) as the end of the document, which is why the page is cut off at that level</li> </ul> <p>So this is basically a case of invalid input (so I wouldn’t call this a bug). If we want to handle this more gracefully, we could use the <a href="https://github.com/svbergerem/markdown-it-sanitizer">markdown-it-sanitizer plugin</a>, that should be more or less plug-and-play.</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>