怎样防止html代码格式化?
@ego008 我在contentfmt.go添加蓝下面的代码
input = videoRegexp.ReplaceAllString(input, `
<div id="video" style="width:600px;height:400px;"></div>
< script type = "text/javascript" >
var videoObject = {
container: '#video',
variable: 'player',
flashplayer: false,
video: '$1'
};
var player = new ckplayer(videoObject); < /script>
`)
但是在网页里却变成里下面的代码
<p><div id="video" style="width:600px;height:400px;"></div></p><p>< script type = "text/javascript" ><br>var videoObject = {</p><p>container: '#video',</p><p>variable: 'player',</p><p>flashplayer: false,</p><p>video: 'http://h.ddd.xxx/20171105/WLHDN3G1/index.mp4'<br>};<br>var player = new ckplayer(videoObject); < /script>/<br></p>
<div id="video" style="width:600px;height:400px;"></div>
想问以下怎样才能实现
input = videoRegexp.ReplaceAllString(input, `
<div id="video" style="width:600px;height:400px;"></div>
< script type = "text/javascript" >
var videoObject = {
container: '#video',
variable: 'player',
flashplayer: false,
video: '$1'
};
var player = new ckplayer(videoObject); < /script>
`)
不被格式化,又能正确获取s1变量的值呢?
0
See Also
Nearby
- 上一篇 › 优化struct 结构,减少内存分配
- 下一篇 › golang 八行代码实现的一致性哈希
写成单行,
示例 https://github.com/ego008/goyoubbs/blob/master/util/contentfmt.go#L74