Closed p1ho closed 4 years ago
Still doesn't work 100%... but no errors. This may need a deeper dive.
I have tried updating ./showdown.js
from the showdown repo, but still doesn't change anything.
I recommend testing out showdown's compatability with IE11 first, then we can go from there.
Yep sounds good. IE is a terrible browser. I don’t like accounting for it. So if people want a fix happy to accept PR. But not keen to do myself
Still doesn't work 100%... but no errors. This may need a deeper dive.
Can you do a log of the showdown js
sorry, what kind of log are you looking for?
Like the console output of this: https://github.com/oscarmorrison/md-page/blob/master/src/script.js#L86
To work out whether IE11 is being silly and not rendering the blocks, or because showdown is not working
Yeah there's definitely something wrong with the way IE11 processes showdown. here's the test html
<script src="https://livejs.com/live.js"></script>
<script src="src/showdown.js"></script>
<script src="src/script.js"></script><noscript>
# test h1
## test h2
### test h3
#### test h4
##### test h5
###### test h6
IE 11 spits out
<p># test h1 ## test h2 ### test h3 #### test h4 ##### test h5 ###### test h6</p>
whereas the same file spits out the correct string in Chrome/Firefox
<h1 id="test-h1">test h1</h1>
<h2 id="test-h2">test h2</h2>
<h3 id="test-h3">test h3</h3>
<h4 id="test-h4">test h4</h4>
<h5 id="test-h5">test h5</h5>
<h6 id="test-h6">test h6</h6>
Yep. Thanks @p1ho wanted to work out what was exact error. Next steps would be to verify showdown normally works with IE11
can you try: http://demo.showdownjs.com/
If that works, then we should remove showdown manually dep, and use npm for it
That works, yeah I'll try including it via npm, see if that works
sounds good, thankyou
It doesn't work, it's still outputting the wrong string.
<script src="https://livejs.com/live.js"></script>
<script src="node_modules/showdown/dist/showdown.js"></script>
<script src="src/script.js"></script><noscript>
then running in console
var converter = new showdown.Converter(),
text = '# hello, markdown!',
html = converter.makeHtml(text);
^ That works!
So what about just
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.9.1/showdown.min.js"></script>
<script src="src/script.js"></script><noscript>
Found the problem, this line
var markdown = document.querySelector('noscript').innerText
in IE 11 returns a string without new line
Alright, I got it to work!
Basically, IE 11 will only preserve text formatting on text extraction for <pre>
and <textarea>
, we could try to use any of the 2 instead of <noscript>
, but this breaks backward compatibility (people who still had <noscript>
in their code will find that it stopped working).
So the trick is, when browser is IE 11, we clone the <noscript>
text content into a <pre>
(note: this preserves formatting because it's not text extraction), then extract text from the temp <pre>
element.
Will open a PR
nice work. yeah that sounds good. i think its very important to be able to retain:
<script type="text/javascript" src="https://rawcdn.githack.com/oscarmorrison/md-page/abe58a8f057636e8d865324b5f5821c760f3f6e9/md-page.js"></script><noscript>
As long as people have been using the following
<script src="https://rawcdn.githack.com/oscarmorrison/md-page/master/md-page.js"></script><noscript>
as instructed in the README.md, this shouldn't break anything for existing users.
can do it for ie only doing some like:
if (window.navigator.userAgent.indexOf("MSIE ")){
}
@ji-ryoo You should be able to use it in IE 11 no problem now, feel free to open issues if you find something else not working. Thanks for letting us know.
Note: the rawcdn link might take time to refresh, give it a bit of time.
Edit: https://oscarmorrison.com/md-page/ works on my machine now
Nice work @p1ho
Closed in #47
It would appear that IE may require more polyfills than we initially thought. I can try to get to the bottom of this.
Relevant:
43 #44