Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown files starting with a HTML tag do not get rendered on Windows #58

Open
nilslindemann opened this issue Jun 4, 2019 · 13 comments
Labels
Firefox bug Caused by a bug in firefox, help by voting on the bugizlla ssue !

Comments

@nilslindemann
Copy link

Hi, thanks for the addon.

It does not render this file: https://github.com/snabbdom/snabbdom/blob/master/README.md when downloaded and then opened from within the file manager.

I guess that is because the file is huge. Smaller files get rendered without problems.

BTW, the Gitlab Markdown viewer correctly renders it.

@Cimbali
Copy link
Owner

Cimbali commented Jun 5, 2019

Hi @heronils the file seems to render fine for me. Can you specify how you access the file? In particular there is a known bug in firefox due to which navigating to a local file by clicking links to it causes the add-on not to render the file (see #45). This also affects Gitlab Markdown Viewer.

Where you’re on the non-rendered page, can you try re-loading it by copying the url pasting it into a address bar (F5 will not work)? Or from the directory view, copy the link to the file (right click > copy link location) and paste the address in the directory bar, instead of clicking the link directly.

@nilslindemann
Copy link
Author

I just found out that it seems to be the first line, the image. If i remove that, it will render.

So this does not render (i can see the three hashes):

<img src="lorem.jpg">

### Text

But this does render (it gets expanded to a h3 heading):

### Text

The Gitlab viewer renders both.

Can you reproduce this?

@nilslindemann
Copy link
Author

Here is a screenshot:

Rendered Markdown

The related markdown:

<img src="Lion.png"/>

### Text

@nilslindemann
Copy link
Author

I just see the Gitlab viewer also has some delay, it first shows it like in the screenshot, then, after three seconds it reloads the page and renders it.

@nilslindemann
Copy link
Author

I can also reproduce the behaviour when navigating to it by clicking a link. Both dont render it. It only gets rendered in the Gitlab viewer when i open the file by clicking it in the file manager (md_auto_file → open is assigned to "C:\Program Files\Mozilla Firefox\firefox.exe" "%1").

@Cimbali
Copy link
Owner

Cimbali commented Jun 10, 2019

The related markdown:

<img src="Lion.png"/>

### Text

This again works fine for me, on FF 66.0.5 64-bit on linux. We’ll need some more info to troubleshoot:

  • Can you specify what your setup is?
  • Can you also make sure no other add-on is interfering? i.e. try disabling all the other add-ons and seeing whether you can still reproduce the bug. If this fails, reactivate add-ons one by one until the bug appears again.
  • If this fails, I suspect firefox somehow attempts to detect whether the text file is html or text, and the leading <img /> tag fools it. This would explain why the image is displayed instead of its source code. To confirm this, can you also report, both for the wrongly rendered page (the image with the un-rendered ### text) and for the original page (i.e. accessing the page with the add-on disabled):
    • Each page’s « type », which is displayed in the Tools > Page Info (Ctrl - I) menu.
    • Each page's source code. For this, select all the text in the page and use « View Selection Source ». NB: this is different from the Tools > Web developer > Page Source (Ctrl + U) menu item, and should give you something like:
      <html><head><link rel="alternate stylesheet" type="text/css" href="resource://content-accessible/plaintext.css" title="Wrap Long Lines"></head><body><pre>&lt;img src="Lion.png"/&gt;
      
      ### Text
      </pre></body></html>

@nilslindemann
Copy link
Author

Setup is Windows 7, Firefox 67.0.1 (64-Bit), other addons disabled.

I found that it seems to be related to the encoding. Tested with Notepad++. Only if the markdown is UTF 8 BOM encoded it gets correctly rendered. Not with other encodings. When the encoding is other than UTF 8 BOM Firefox warns about the missing encoding declaration in the console.

The detailed behaviour:

1 – Addon enabled (other addons disabled):

1.1 – Saved as UTF 8 BOM: The Markdown document gets correctly rendered, the type is text/plain, Firefox assumes UTF 8 as encoding. The formatted HTML is

<html>
   <head>
      ...
   </head>
   <body>
      <div id="__markdown-viewer__tools" class="floating">
         ...
      </div>
      <div class="markdownRoot">
         <img src="lion.png">
         <h3 id="text">Text</h3>
      </div>
   </body>
</html>

1.2 – Saved with ANSI or UTF 8 no BOM: The markdown gets rendered like in my screenshot, the type is text/html, Firefox assumes UTF 8 as encoding. The HTML is exactly

<html><head></head><body><img src="lion.png">

### Text</body></html>

2 – All Addons disabled:

2.1 – Encoding is UTF 8 BOM: Firefox shows the markdown as it is written, the type is text/plain, Firefox assumes UTF 8 as encoding, the source code is like the one you gave in your previous post (just in german).

2.2 – Encoding is UTF 8, no BOM: Firefox behaves like in 1.2

@Cimbali
Copy link
Owner

Cimbali commented Jun 25, 2019

Seems to be a firefox bug, like many of the quirks we get from file:// urls in forefox. Work-around is to use BOM, sorry I can’t do better than this at the moment.

@Cimbali Cimbali added the Firefox bug Caused by a bug in firefox, help by voting on the bugizlla ssue ! label Jun 25, 2019
@nilslindemann
Copy link
Author

No problem, for me personally that resolves the issue.

@Cimbali
Copy link
Owner

Cimbali commented Jun 30, 2019

Actually this bug is marked resolved in Firefox 66. With 67.0.1 you should not be affected.

@nilslindemann
Copy link
Author

I just tested it on my Windows 7 Firefox 67.0.4 x64. The behaviour is still identical to my above report.

@Cimbali
Copy link
Owner

Cimbali commented Jul 6, 2019

I can reproduce this with Firefox 67.0.4 (64 bits) on Windows 10. The page is correctly decoded as UTF-8 in both cases, however in one case (no BOM) the add-on is not rendering the page.

It seems that if the first non-whitespace (and non-BOM) character is a valid tag (here <img /> then the document is detected as html).

@Cimbali Cimbali changed the title Snabbdom readme does not get rendered. Markdown files starting with a HTML tag do not get rendered on Windows Aug 8, 2019
@Cimbali
Copy link
Owner

Cimbali commented Jan 17, 2023

The default way of opening a local file in v2 (#99) : opening ext+view-markdown:file:///path/to/file.md and confirming local file access, is not affected by this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Firefox bug Caused by a bug in firefox, help by voting on the bugizlla ssue !
Projects
None yet
Development

No branches or pull requests

2 participants