From 5092c03f1fa048589f4db3bddffc3de1b5b54de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=AE=E7=94=9F?= Date: Wed, 18 Aug 2021 13:11:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=B8=80=E4=B8=AA=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E4=B8=8D=E5=B0=8F=E5=BF=83=E5=8E=BB=E9=99=A4=E4=BA=86=20iframe?= =?UTF-8?q?=20=E5=B1=9E=E6=80=A7=E7=9A=84=E9=99=84=E5=8A=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/render/ocean_press_render.go | 26 ++++++++++++------------- src/render/ocean_press_render_custom.go | 17 +++++++++++++++- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/render/ocean_press_render.go b/src/render/ocean_press_render.go index 7a51774..3bf9460 100644 --- a/src/render/ocean_press_render.go +++ b/src/render/ocean_press_render.go @@ -315,19 +315,19 @@ func (r *OceanPressRender) renderAudio(node *ast.Node, entering bool) ast.WalkSt return ast.WalkContinue } -func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus { - if entering { - r.Tag("div", [][]string{{"class", "iframe"}}, false) - tokens := node.Tokens - if r.Options.Sanitize { - tokens = sanitize(tokens) - } - tokens = r.tagSrcPath(tokens) - r.Write(tokens) - r.Tag("/div", nil, false) - } - return ast.WalkContinue -} +// func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus { +// if entering { +// r.Tag("div", [][]string{{"class", "iframe"}}, false) +// tokens := node.Tokens +// if r.Options.Sanitize { +// tokens = sanitize(tokens) +// } +// tokens = r.tagSrcPath(tokens) +// r.Write(tokens) +// r.Tag("/div", nil, false) +// } +// return ast.WalkContinue +// } // func (r *OceanPressRender) Render() (output []byte) { // output = r.BaseRenderer.Render() diff --git a/src/render/ocean_press_render_custom.go b/src/render/ocean_press_render_custom.go index a309098..c478669 100644 --- a/src/render/ocean_press_render_custom.go +++ b/src/render/ocean_press_render_custom.go @@ -65,7 +65,22 @@ func (r *OceanPressRender) Render() (html string, xml string) { return html, xml } - +func (r *OceanPressRender) renderIFrame(node *ast.Node, entering bool) ast.WalkStatus { + if entering { + attr := [][]string{{"class", "iframe"}} + // 添加自定义属性 + attr = append(attr, node.KramdownIAL...) + r.Tag("div", attr, false) + tokens := node.Tokens + if r.Options.Sanitize { + tokens = sanitize(tokens) + } + tokens = r.tagSrcPath(tokens) + r.Write(tokens) + r.Tag("/div", nil, false) + } + return ast.WalkContinue +} // renderImage 为了实现居中效果 func (r *OceanPressRender) renderImage(node *ast.Node, entering bool) ast.WalkStatus { if entering {