【发布时间】:2016-04-09 02:28:12
【问题描述】:
我正在关注如何使用 Markdown 以及何时使用的教程
# H1
## H2
### H3
#### H4
##### H5
###### H6
H1 被包裹在井中。当我从控制台查看输出时,它显示
<p class="content-markdown"><pre><code> # H1
</code></pre><h2 id="h2">H2</h2>
<h3 id="h3">H3</h3>
<h4 id="h4">H4</h4>
<h5 id="h5">H5</h5>
<h6 id="h6">H6</h6>
<h2 id="alt-h2">Alt-H2</h2>
</p>
如果我做广告
#
在 h1 之上,它显示正常,但是爆炸标志现在在一个井中
这是我的脚本标签
<script type="text/javascript">
$(document).ready(function(){
$(".content-markdown").each(function(){
var content = $(this).text()
console.log(content)
var markedContent = marked(content)
console.log(markedContent)
$(this).html(markedContent)
})
})
这是在我的头标签中,我认为这并不重要,但我可能是错的
<script src="https://code.jquery.com/jquery-1.12.3.min.js"
integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ=" crossorigin="anonymous"></script>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" >
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" >
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js"></script>
这可能是什么原因造成的?欢迎大家指导
【问题讨论】:
-
这是您在网站中使用的降价解析器的一个特定问题... PageDown,StackExchange 使用的(也由他们开发)没有遇到这个问题。
-
是什么原因造成的?因为在我正在观看的教程视频中没有发生这种情况
-
Markdown 文档的开头似乎有一些额外的空格。当您从 HTML 文档中提取 Markdown 时(但您没有显示该部分),请检查您的 HTML 是否有空格。
-
@Waylan 就是这样。删除了空格,它工作正常。如果你回答我本可以给你信用
-
我刚刚将我的评论复制到一个答案中。随意接受它。
标签: javascript jquery html markdown