Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit9fb5ca5

Browse files
author
mydearxym
committed
chore(editor-js): md-editor - change parse_content -> parse_inline
1 parentc2ac6e3 commit9fb5ca5

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎lib/helper/converter/md_to_editor.ex‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Helper.Converter.MdToEditor do
55
see https://editorjs.io/
66
"""
77

8-
@supported_header["h1","h2","h3"]
8+
@supported_header["h1","h2","h3","h4","h5","h6"]
99

1010
@specparse(binary|[any])::any
1111
defparse(mdstring)do
@@ -22,12 +22,12 @@ defmodule Helper.Converter.MdToEditor do
2222
editor_blocks
2323
end
2424

25-
#TODO: parse h4-6 as h3
25+
#parse markdown header to editor's header
2626
defpparse_block({type,_opt,content})
2727
whentypein@supported_headerdo
2828
content_text=
2929
Enum.reduce(content,[],fncontent_item,acc->
30-
parsed=parse_content(type,content_item)
30+
parsed=parse_inline(type,content_item)
3131
acc++parsed
3232
end)
3333

@@ -45,10 +45,11 @@ defmodule Helper.Converter.MdToEditor do
4545
}
4646
end
4747

48+
# parse markdown paragraph to editor's paragraph
4849
defpparse_block({"p",_opt,content})do
4950
content_text=
5051
Enum.reduce(content,[],fncontent_item,acc->
51-
parsed=parse_content("p",content_item)
52+
parsed=parse_inline("p",content_item)
5253
acc++parsed
5354
end)
5455

@@ -67,25 +68,25 @@ defmodule Helper.Converter.MdToEditor do
6768
end
6869

6970
# 字符串直接返回,作为 editor.js 中的 text/data/code 等字段
70-
defpparse_content(content)whenis_binary(content)do
71+
defpparse_inline(content)whenis_binary(content)do
7172
content
7273
end
7374

7475
# TODO: editor.js 暂时不支持 del 标签,所以直接返回字符串内容即可
75-
defpparse_content({"del",[],[content]})do
76+
defpparse_inline({"del",[],[content]})do
7677
content
7778
end
7879

79-
defpparse_content(_type,content)whenis_binary(content)do
80+
defpparse_inline(_type,content)whenis_binary(content)do
8081
content
8182
end
8283

83-
defpparse_content(type,{_type,_opt,[content]})
84+
defpparse_inline(type,{_type,_opt,[content]})
8485
whentypein@supported_headerdo
85-
parse_content(content)
86+
parse_inline(content)
8687
end
8788

88-
# defpparse_content({type, _opt, content})
89+
# defpparse_inline({type, _opt, content})
8990
# when type == "h1" or type == "h2" or type == "h3" do
9091
# content
9192
# end

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp