hwp_script_to_latex 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/hwp_script_to_latex/converter.rb +13 -4
- data/lib/hwp_script_to_latex/version.rb +1 -1
- data/rules.json +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 472ce20026509ccfbf8c95663d56a3927f14396b2501f48b54c425845e376d36
|
4
|
+
data.tar.gz: b1d9f352393667673a744c0d1eb8c0662a3ef9dcae7449069d40fa10b4e4a032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b467a7e8f8d0f74a0a4e6aa2445346cf8acaf96ea3bf2d9d68372dbe5a840b49f355bbe575d997f32849f2baa235b925ee81e5aa22e51d407e8bdfb86622798e
|
7
|
+
data.tar.gz: 6695587fd23de9c283fc75dbe5101df656f4dc4e2c69ab6e641441582365039c7b9e99f76bdcaba9872e121f5a4737359615bd2ec06c473f5c5d7deeb8c7d35e
|
@@ -18,7 +18,7 @@ module HwpScriptToLatex
|
|
18
18
|
|
19
19
|
def convert(script, math_mode: false, display_mode: false)
|
20
20
|
# Sanitize for starting convert
|
21
|
-
result =
|
21
|
+
result = pre_sanitize(script)
|
22
22
|
|
23
23
|
# 키워드 치환
|
24
24
|
result = replace_keywords(result, @keywords)
|
@@ -37,8 +37,8 @@ module HwpScriptToLatex
|
|
37
37
|
result = decorate_displaystyle(result)
|
38
38
|
end
|
39
39
|
|
40
|
-
#
|
41
|
-
result =
|
40
|
+
# Sanitize result for removing dirty spaces
|
41
|
+
result = post_sanitize(result)
|
42
42
|
|
43
43
|
# Math mode
|
44
44
|
if math_mode
|
@@ -50,15 +50,24 @@ module HwpScriptToLatex
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
|
53
|
+
# 변환 전 sanitize
|
54
|
+
def pre_sanitize(script)
|
54
55
|
# 족보닷컴 텍스트 제거
|
55
56
|
jokbo_regex = %r(from\s*=+(?:족보닷컴.*)=+)
|
56
57
|
script = script.gsub(jokbo_regex, "")
|
57
58
|
# 2개 이상의 공백을 하나의 공백으로 치환
|
58
59
|
script = script.gsub(/\s+/, " ").strip
|
60
|
+
# 백슬래시를 rm으로 치환
|
61
|
+
script = script.gsub(/\\/, " \\rm ")
|
59
62
|
return script
|
60
63
|
end
|
61
64
|
|
65
|
+
# 변환 후 sanitize
|
66
|
+
def post_sanitize(script)
|
67
|
+
# 2개 이상의 공백을 하나의 공백으로 치환
|
68
|
+
script = script.gsub(/\s+/, " ").strip
|
69
|
+
end
|
70
|
+
|
62
71
|
def replace_keywords(script, keywords)
|
63
72
|
keywords.each do |keyword|
|
64
73
|
full_match1 = script.match(/(?<!\\)([^\\\s]*)(#{keyword[:regex]})/).to_s
|
data/rules.json
CHANGED