jquery - Internet Explorer 中的 Markdown 失败

标签 jquery css markdown jquery-1.9 wmd-markdown

我正在使用 this jQuery Markdown from arhpreston为了我的目的。我的 jQuery 代码(虽然无关紧要)是:

var converter = new Markdown.Converter();
$(document).ready(function(e) {
    $('#content').html( converter.makeHtml($('#content').text()) );
});

其中,#content 是一个 div:

<div id="content">This is another of most common type of error. It is usually encountered when you are trying something which needs a user registration(at the very least). If you haven't registered on the hub yet, **Gods help you!**.

Anyways, the hub is mostly open for registrations on weekends(*generally* Sunday; sometimes Saturday too). Keep looking at the **Hub Topic** for the notifying information on the registration details. 

### NOTE
You must not, under any non-dire circumstance ask any Admin to get your nick registered. We *WILL* be banning you. It is annoying if nothing else.</div>

一切正常,我一点问题也没有。唯一的问题是文本在 Internet Explorer 中被解析为半 HTML,如屏幕截图所示:

MS IE sucks, as usual

MS IE 和往常一样糟糕

从屏幕截图中可以看出,我所有的强体和斜体都使用正确的 HTML 进行了解析,但所有其他标记都失败了。链接(使用 [1]: 方案)会被解析,但不会链接到实际内容。它们只是作为文本附加在末尾。

hr 之间的以下内容显示了应该如何解析它。


这是另一种最常见的错误类型。当您尝试需要用户注册(至少)的事情时,通常会遇到这种情况。如果你还没有在hub上注册过,求大神帮忙!

无论如何,中心主要在周末开放注册(一般星期日;有时星期六)。请继续查看Hub 主题,以获取有关注册详细信息的通知信息。

注意

在任何非恶劣情况下,您不得要求任何管理员注册您的昵称。我们禁止您。如果没有别的,这很烦人。


我为此使用 IE 7。但问题也存在于 IE 8 上。 jQuery 版本是 1.9.1。该页面在任何其他操作系统(Windows Xp 到 8、*nix 和 Leopard)中的任何其他浏览器(Opera、Firefox、Chrome、Safari)上解析都没有问题。通过向 IE 用户显示使用其他浏览器的消息,我没有任何问题。 只想知道这个故障是从哪里来的?

最佳答案

尝试将对 .text() 的调用替换为对 .html() 的调用。我还没有验证这一点,但确实记得在早期版本的 IE 中有过这样的效果。

关于jquery - Internet Explorer 中的 Markdown 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15753198/

相关文章:

jquery,递归替换多个元素

javascript - Jquery attr 函数与 is 函数

javascript - jQuery css 动画可见性

html - 如何在 CSS 中创建一个变窄的人字形?

jquery - 隐藏在 css 中的可见性不适用于上一页

javascript - 如何为 marked.js 编写自定义 InlineLexer 规则?

javascript - 在 jquery 自动完成插件中显式调用自动完成函数

javascript - Safari 在切换 css 文件后忽略 css dir ="ltr"

github - Github Markdown 中的差异语法突出显示

javascript - 使用 React 以类似于 Markdown 的方式向用户评论添加功能