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.

Commit584f289

Browse files
author
mydearxym
committed
feat: add chinese format for better look
1 parent5b321f3 commit584f289

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
defmoduleHelper.Converter.ChineseConventiondo
2+
@moduledoc"""
3+
follow's https://github.com/sparanoid/chinese-copywriting-guidelines
4+
遵循中文排版指南
5+
6+
- 自动添加空格
7+
- 中文状态下输入的的 "" 和 '' 会被自动转换成「」以及 『』
8+
9+
inspired by wordpress plugin cover-lover:
10+
https://cn.wordpress.org/plugins/corner-bracket-lover/
11+
"""
12+
13+
requirePangu
14+
15+
@doc"""
16+
format chinese stirng follows github: sparanoid/chinese-copywriting-guidelines.
17+
18+
example: "Sephiroth見他”這等’神情‘“,也是悚然一驚:不知我這Ultimate Destructive Magic是否對付得了?"
19+
to: "Sephiroth 見他「這等『神情』」, 也是悚然一驚: 不知我這 Ultimate Destructive Magic 是否對付得了?"
20+
"""
21+
@specformat(binary)::binary
22+
defformat(text)do
23+
text
24+
|>Pangu.spacing()
25+
|>cover_brackets
26+
end
27+
28+
# covert chinese "" and '' to 「」& 『』
29+
defpcover_brackets(text)do
30+
text
31+
|>String.replace("“","「")
32+
|>String.replace("”","」")
33+
|>String.replace("‘","『")
34+
|>String.replace("’","』")
35+
end
36+
end

‎mix.exs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ defmodule GroupherServer.Mixfile do
104104
{:quantum,"~> 2.3"},
105105
{:html_sanitize_ex,"~> 1.3"},
106106
{:open_graph,"~> 0.0.3"},
107-
{:earmark,"~> 1.4.0"}
107+
{:earmark,"~> 1.4.0"},
108+
# 遵循中文排版指南
109+
# https://github.com/cataska/pangu.ex
110+
{:pangu,"~> 0.1.0"}
108111
]
109112
end
110113

‎mix.lock‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"mochiweb":{:hex,:mochiweb,"2.18.0","eb55f1db3e6e960fac4e6db4e2db9ec3602cc9f30b86cd1481d56545c3145d2e",[],[],"hexpm"},
5454
"nanoid":{:hex,:nanoid,"2.0.1","7ddfe8f3abf1a559c3b673878efbe4feb2c81a657e3f0533aa28be5885257674",[:mix],[],"hexpm"},
5555
"open_graph":{:hex,:open_graph,"0.0.3","6edb31150443058bac6e046a3462e5a1fe9818dbc79f1bee028cfea1e6589e61",[:mix],[{:httpoison,"~> 1.0",[hex::httpoison,repo:"hexpm",optional:false]}],"hexpm"},
56+
"pangu":{:hex,:pangu,"0.1.0","9f9e06418212017bb076034865462e92effed4e5b18c063d4448c186f12a6f0a",[:mix],[],"hexpm"},
5657
"parse_trans":{:hex,:parse_trans,"3.3.0","09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1",[:rebar3],[],"hexpm"},
5758
"phoenix":{:hex,:phoenix,"1.4.9","746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974",[:mix],[{:jason,"~> 1.0",[hex::jason,repo:"hexpm",optional:true]},{:phoenix_pubsub,"~> 1.1",[hex::phoenix_pubsub,repo:"hexpm",optional:false]},{:plug,"~> 1.8.1 or ~> 1.9",[hex::plug,repo:"hexpm",optional:false]},{:plug_cowboy,"~> 1.0 or ~> 2.0",[hex::plug_cowboy,repo:"hexpm",optional:true]},{:telemetry,"~> 0.4",[hex::telemetry,repo:"hexpm",optional:false]}],"hexpm"},
5859
"phoenix_ecto":{:hex,:phoenix_ecto,"4.0.0","c43117a136e7399ea04ecaac73f8f23ee0ffe3e07acfcb8062fe5f4c9f0f6531",[:mix],[{:ecto,"~> 3.0",[hex::ecto,repo:"hexpm",optional:false]},{:phoenix_html,"~> 2.9",[hex::phoenix_html,repo:"hexpm",optional:true]},{:plug,"~> 1.0",[hex::plug,repo:"hexpm",optional:false]}],"hexpm"},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp