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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b72e8832e4c28f5e9eb5667a196d0960aa4e968903793d7ba6aed8cc11c2945f
4
- data.tar.gz: a65a6f06d61ac8da34a373ee94d44f024f7917ae7621cd2a7e6505e8080cc46c
3
+ metadata.gz: b605190868ff249a203b7ef69482651fe321dcbb6d3ac75965cdeff3af95eaed
4
+ data.tar.gz: 609945636fe4c3d775601a06dc9892f45005e923de913895fce0ea0bba55044b
5
5
  SHA512:
6
- metadata.gz: 7fd90ae66f1e3bc7ec8868d63f01b62e3b9a20c7b28c4c151360f575a71b2d4e352d65b81a2c5dece69deaec8461f8d2709a4f82e35610bbcec70c5095761510
7
- data.tar.gz: c83c769442f60005b40ff917c04bc5f3f42aeb8dac325cd37fad29b580b2c173ce08bb52dc9780aaec56a9e32b8527c9d3c276180b00d59623d51a029a20aa69
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
- keywords.each do |keyword|
102
- keyword_regex = get_keyword_regex(keyword)
103
- before_script = script
104
- script = script.gsub(keyword_regex, keyword[:latex])
105
- while before_script != script
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
@@ -1,3 +1,3 @@
1
1
  module HwpScriptToLatex
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hwp_script_to_latex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bluesh55