hwp_script_to_latex 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fab7041db73e13ffb2d90b2ea115186e74cb3423f6a8d32ee3d363b6b9b81e6
4
- data.tar.gz: 02f94703333f490fe69013740c91fc6a9727adcf42f016d5c18885ba122955a9
3
+ metadata.gz: 472ce20026509ccfbf8c95663d56a3927f14396b2501f48b54c425845e376d36
4
+ data.tar.gz: b1d9f352393667673a744c0d1eb8c0662a3ef9dcae7449069d40fa10b4e4a032
5
5
  SHA512:
6
- metadata.gz: 80da2117f7744411cac72d6e4ddd9aa9378adaf9fa3166cfb956e47a96a08fb96511c72aca3ef87c3f0f8fc7e39d723bbf0947ba73cef6132086fb485e69f7d6
7
- data.tar.gz: b795c64023799a7485e21da1fcd33e4cc6a9370869dc3557b8cc8d52bd4b220aa69669944fcc0135fd386c688c7ce85db04b0712114d592f1ab174c041c27c35
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 = sanitize(script)
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
- # ReSanitize result for removing dirty spaces
41
- result = sanitize(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
- def sanitize(script)
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
@@ -1,3 +1,3 @@
1
1
  module HwpScriptToLatex
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/rules.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "latex": " \\backsim "
30
30
  },
31
31
  {
32
- "regex": "\\\xf3\\\xb0\\\x81\\\x80",
32
+ "regex": "\\xf3\\xb0\\x81\\x80",
33
33
  "latex": " \\backsim "
34
34
  },
35
35
 
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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bluesh55