hwp_script_to_latex 1.3.0 → 1.3.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 +20 -7
- data/lib/hwp_script_to_latex/version.rb +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: b605190868ff249a203b7ef69482651fe321dcbb6d3ac75965cdeff3af95eaed
|
4
|
+
data.tar.gz: 609945636fe4c3d775601a06dc9892f45005e923de913895fce0ea0bba55044b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d640ddfb7c1615b737d27baf1954a57d68af1bf00578f78d7c7cd83ed374442eea1896866cb7b456ae1d261b2fedf1f02f63bd149d468964fea103e5e5a41a4a
|
7
|
+
data.tar.gz: 250c3abe6c18e60040e7e5102164814561bbc86f4012c4bf47ce415d62e0c179e78a57846670076d72bc67ed0ac6fe0cdc3aeb2c0803472b9fc89953c8536815
|
@@ -24,10 +24,10 @@ module HwpScriptToLatex
|
|
24
24
|
def convert(script, math_mode: false, display_mode: false)
|
25
25
|
# Sanitize for starting convert
|
26
26
|
result = pre_sanitize(script)
|
27
|
-
# Simple Command 치환
|
28
|
-
result = replace_simple_commands(result)
|
29
27
|
# 키워드 치환
|
30
28
|
result = replace_keywords(result)
|
29
|
+
# Simple Command 치환
|
30
|
+
result = replace_simple_commands(result)
|
31
31
|
|
32
32
|
# 특수 형태의 명령어 치환
|
33
33
|
# Case 1. 루트 변환
|
@@ -98,14 +98,27 @@ module HwpScriptToLatex
|
|
98
98
|
|
99
99
|
def replace_keywords(script)
|
100
100
|
keywords = @meta_keywords + @command_keywords + @symbol_keywords + @reserved_keywords
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
matched_count = 0
|
102
|
+
|
103
|
+
# 1star(2star(3starcdotsstar(99star100))cdots)
|
104
|
+
# 위와 같은 경우 이중 루프 cdots 부터 매치되기 시작하면 star 때문에
|
105
|
+
# 제대로 변환되지 않음.
|
106
|
+
# 그러므로 전체 키워드를 검사하는 루프(loop 2)를
|
107
|
+
# 이중 루프로 변환이 완료될 때 까지 반복함(loop 1)
|
108
|
+
# 속도는 느려지겠지만 대안을 찾을 때 까지 이대로 사용하려고 함
|
109
|
+
loop do # loop 1
|
110
|
+
matched_count = 0
|
111
|
+
keywords.each do |keyword|
|
112
|
+
keyword_regex = get_keyword_regex(keyword)
|
106
113
|
before_script = script
|
107
114
|
script = script.gsub(keyword_regex, keyword[:latex])
|
115
|
+
while before_script != script # loop 2
|
116
|
+
matched_count += 1
|
117
|
+
before_script = script
|
118
|
+
script = script.gsub(keyword_regex, keyword[:latex])
|
119
|
+
end
|
108
120
|
end
|
121
|
+
break if matched_count == 0
|
109
122
|
end
|
110
123
|
|
111
124
|
return script
|