CNode

问个问题 为什么node-markdown 转出来的内容会直接输出而不是变成html?

Qq1270989发布于13 年前最后回复13 年前5 回复5561 浏览0 收藏

http://198.100.114.49:8080/

地址如上.

div.content-perspective
	div.content
		div.content-inner
		     h3 
			a(href="/blog/#{blogc._id}")=blogc.title
			div.article=md(blogc.content)

jade模版. md 是传过来的

var md = require('node-markdown').Markdown;

转完之后直接显示了 不是html <>都变成了

&lt;p&gt;&lt;code&gt;javascript
var this = o;
$(this).addClass('a');
&lt;/code&gt;&lt;/p&gt;

求指导.

查看回复

回复 (5)

Q
q1270989#1·13 年前

自己顶一下吧~

L
leizongmin#2·13 年前
引用 q1270989自己顶一下吧
ReferenceError: /mydata/myweb/nodejs/views/blog-list.jade:27


current_user is not defined
    at eval (eval at <anonymous> (/mydata/myweb/nodejs/node_modules/jade/lib/jade.js:171:8), <anonymous>:126:6)
    at /mydata/myweb/nodejs/node_modules/jade/lib/jade.js:172:35
    at Object.exports.render (/mydata/myweb/nodejs/node_modules/jade/lib/jade.js:206:14)
    at View.exports.renderFile [as engine] (/mydata/myweb/nodejs/node_modules/jade/lib/jade.js:233:13)
    at View.render (/mydata/myweb/nodejs/node_modules/express/lib/view.js:75:8)
    at Function.app.render (/mydata/myweb/nodejs/node_modules/express/lib/application.js:501:10)
    at ServerResponse.res.render (/mydata/myweb/nodejs/node_modules/express/lib/response.js:755:7)
    at render (/mydata/myweb/nodejs/controllers/blog.js:37:9)
    at _all (/mydata/myweb/nodejs/node_modules/eventproxy/lib/eventproxy.js:230:16)
    at EventProxy.trigger (/mydata/myweb/nodejs/node_modules/eventproxy/lib/eventproxy.js:133:22)
L
leizongmin#3·13 年前

应该是模板默认对输出的变量进行了转义(出于安全考虑,很多模板默认都这样) 具体神马原因,仔细看看文档就知道了。

(俺不懂Jade模板,表示很羡慕楼主)

Q
q1270989#4·13 年前
引用 q1270989自己顶一下吧

@leizongmin 好了 sorry 调试代码忘记去掉了

参与回复
登录后即可参与回复。登录