Skip to content
This repository was archived by the owner on Sep 17, 2023. It is now read-only.

Commit 5092c03

Browse files
committed
上一个改动不小心去除了 iframe 属性的附加功能
1 parent 0ed3e1a commit 5092c03

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

src/render/ocean_press_render.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,19 @@ func (r *OceanPressRender) renderAudio(node *ast.Node, entering bool) ast.WalkSt
315315
return ast.WalkContinue
316316
}
317317

318-
func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus {
319-
if entering {
320-
r.Tag("div", [][]string{{"class", "iframe"}}, false)
321-
tokens := node.Tokens
322-
if r.Options.Sanitize {
323-
tokens = sanitize(tokens)
324-
}
325-
tokens = r.tagSrcPath(tokens)
326-
r.Write(tokens)
327-
r.Tag("/div", nil, false)
328-
}
329-
return ast.WalkContinue
330-
}
318+
// func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus {
319+
// if entering {
320+
// r.Tag("div", [][]string{{"class", "iframe"}}, false)
321+
// tokens := node.Tokens
322+
// if r.Options.Sanitize {
323+
// tokens = sanitize(tokens)
324+
// }
325+
// tokens = r.tagSrcPath(tokens)
326+
// r.Write(tokens)
327+
// r.Tag("/div", nil, false)
328+
// }
329+
// return ast.WalkContinue
330+
// }
331331

332332
// func (r *OceanPressRender) Render() (output []byte) {
333333
// output = r.BaseRenderer.Render()

src/render/ocean_press_render_custom.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,22 @@ func (r *OceanPressRender) Render() (html string, xml string) {
6565

6666
return html, xml
6767
}
68-
68+
func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus {
69+
if entering {
70+
attr := [][]string{{"class", "iframe"}}
71+
// 添加自定义属性
72+
attr = append(attr, node.KramdownIAL...)
73+
r.Tag("div", attr, false)
74+
tokens := node.Tokens
75+
if r.Options.Sanitize {
76+
tokens = sanitize(tokens)
77+
}
78+
tokens = r.tagSrcPath(tokens)
79+
r.Write(tokens)
80+
r.Tag("/div", nil, false)
81+
}
82+
return ast.WalkContinue
83+
}
6984
// renderImage 为了实现居中效果
7085
func (r *OceanPressRender) renderImage(node *ast.Node, entering bool) ast.WalkStatus {
7186
if entering {

0 commit comments

Comments
 (0)