【问题标题】:Markdown blockquote failureMarkdown 块引用失败
【发布时间】:2013-04-28 13:14:41
【问题描述】:

我的页面使用this jQuery markdown。 jQuery代码如下:

var converter = new Markdown.Converter();
$(document).ready(function(e) {
    $('#content').html( converter.makeHtml($('#content').html()) );
    /* and some more */
});

这一直运行良好。直到现在我的页面都没有blockquote。今天,我尝试使用 blockquote 内容,但页面没有正确解析 HTML。

文本存储在 MySQL 表中。考虑以下几点:

Just some

> random blockquote content. let's see if it works or not

此文本在markdown editor box 上正确显示:

但是当它作为网页打开时(我使用的是 Opera;但在所有其他浏览器中仍然存在问题,即 Firefox、Chrome 和 IE)

  1. 正常页面显示

  2. 歌剧蜻蜓

  3. 原始文本作为页面源

P.S.:所有图片均为缩略图。点击查看大图。

这是一个显示上述问题的小提琴链接:http://jsfiddle.net/atdEP/

【问题讨论】:

    标签: jquery html css markdown wmd-markdown


    【解决方案1】:

    我不熟悉 markdown,但我认为您将 > 作为 html 实体 I.E > 而不是单个字符。

    如果我通过将字符串硬编码到下面来更改您的小提琴,则 > 从结果屏幕中消失并出现正确的 html。 (在萤火虫中测试)

    <script type="text/javascript">
        var converter = new Markdown.Converter();
        $(document).ready(function (e) {
            $('#content').html(converter.makeHtml('> random blockquote'));
            /* and some more */
        });
    </script>
    

    【讨论】:

      【解决方案2】:

      感谢@Jay,我找到了解决问题的方法。

      与其在转换器中使用.html(),不如在.text() 下完美运行。

      var converter = new Markdown.Converter();
      $(document).ready(function(e) {
          $('#content').html( converter.makeHtml($('#content').text()) );
          /* and some more --------------------- RIGHT HERE  >>>^ */
      });
      

      这是更新后的小提琴:http://jsfiddle.net/atdEP/1/

      【讨论】:

        猜你喜欢
        • 2023-03-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-14
        相关资源
        最近更新 更多