tex2id 1.4.0 → 1.6.0

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: 4dad00dd189b68420286a665d46d5747c7354e05b9daa9bfad36208e30732da2
4
- data.tar.gz: 32f88f87b3bc74c14b0d465b70a8770ee9956cd35de5a0f54b7115a22a7c7c08
3
+ metadata.gz: 5476eb432da2d0c6cc135bd2da0b1eb491cca009cedb50cebab2d080a364ab10
4
+ data.tar.gz: 87a8fe6641b5af03bca1a94971c41cda500babee9a275b5585a157b73935f1fd
5
5
  SHA512:
6
- metadata.gz: 4d2d8a3771820624223bbbaaf080d9ad8bfba91994fcf368997bedba2e28885c29fcfad493b0b4c897073ebf8b6c13b6b6dd466ad1ad449bc23b49e599456aec
7
- data.tar.gz: b1118c58521ca06af0727d433f01cfa6c73329520c5bb921e6807301568d559cf2c8807eac70a580ac8988bcb1b56e7d5e6151c09718c85712ed281c2c85b2f3
6
+ metadata.gz: c6c3ae76103f434fdbd860bd7feb9bb4eabd11eb197ea5c9d0a180f4255bdede2a2d21f8d8e7bfed499f8e4dd375f2c903ced8d5c3a8bea5a94d69e3dd9880a5
7
+ data.tar.gz: 484d9c8d0fb4670ce06f819da0a966b130b48f31327b5536254d8d423da114f858c1e635bee9b2732af4b19ecaaa51b8f4f9e7362d6607d8ccf9b889b1e5047d
data/lib/tex2id/cli.rb CHANGED
@@ -43,27 +43,22 @@ Usage: #{$0} <source_file> [<output_file>]
43
43
  def source
44
44
  case source_file
45
45
  when "-"
46
- $stdin.set_encoding("Windows-31J:UTF-8")
47
46
  $stdin.read
48
47
  else
49
- IO.read(source_file, mode: 'r:Windows-31J:UTF-8')
48
+ IO.read(source_file, mode: 'r')
50
49
  end
51
50
  end
52
51
 
53
52
  def with_output_file_io
54
53
  begin
55
54
  io = if output_file
56
- File.open(output_file, 'w:Windows-31J:UTF-8')
55
+ File.open(output_file, 'w')
57
56
  else
58
- $stdout.set_encoding("Windows-31J")
57
+ $stdout
59
58
  end
60
59
  yield io
61
60
  ensure
62
- if output_file
63
- io.close
64
- else
65
- $stdout.set_encoding("UTF-8")
66
- end
61
+ io.close if output_file
67
62
  end
68
63
  end
69
64
 
@@ -45,6 +45,7 @@ module Tex2id::Converter::Constants
45
45
  'dots' => '<cstyle:数式>...<cstyle:>',
46
46
  'cdots' => '<cstyle:数式><22EF><cstyle:>',
47
47
  'times' => '<cstyle:数式>×<cstyle:>',
48
+ 'div' => '<cstyle:数式>÷<cstyle:>',
48
49
  'quad' => '<cstyle:数式> <cstyle:>',
49
50
  'qquad' => '<cstyle:数式>  <cstyle:>',
50
51
  'alpha' => '<cstyle:数式><03B1><cstyle:>',
@@ -5,32 +5,13 @@ class Tex2id::Converter
5
5
 
6
6
  def initialize(source, only_fix_md2inao: false)
7
7
  @source = source
8
- @use_math = false
9
8
  @only_fix_md2inao = only_fix_md2inao
10
9
  @state_stack = []
11
10
  @token_stack = []
12
11
  end
13
12
 
14
- def use_math? = @use_math
15
-
16
13
  def convert
17
- pass1 = check_use_math(@source)
18
- if use_math?
19
- convert_math(pass1)
20
- else
21
- pass1
22
- end
23
- end
24
-
25
- def check_use_math(source)
26
- source.sub(/\bUseMath:\s+(true|false)\b/m) {
27
- @use_math = (Regexp.last_match[1] == "true")
28
- ""
29
- }
30
- end
31
-
32
- def convert_math(source)
33
- pass1 = convert_display_math(source)
14
+ pass1 = convert_display_math(@source)
34
15
  pass2 = convert_inline_math(pass1)
35
16
  pass2
36
17
  end
@@ -58,7 +39,7 @@ class Tex2id::Converter
58
39
  # do nothing
59
40
  else
60
41
  inline_commands = []
61
- line.gsub!(/<CharStyle:コマンド>[^<]+<CharStyle:>/) do |matched|
42
+ line.gsub!(/<CharStyle:(?:コマンド|コード(文字単位))>[^<]+<CharStyle:>/) do |matched|
62
43
  id = inline_commands.length
63
44
  inline_commands << matched
64
45
  "<tex2id_inline_commands[#{id}]>"
@@ -1,3 +1,3 @@
1
1
  module Tex2id
2
- VERSION = "1.4.0"
2
+ VERSION = "1.6.0"
3
3
  end
data/lib/tex2id.rb CHANGED
@@ -2,7 +2,7 @@ require "tex2id/version"
2
2
 
3
3
  module Tex2id
4
4
  def self.convert(source_filename)
5
- source = IO.read(source_filename, mode: 'r:Windows-31J:UTF-8')
5
+ source = IO.read(source_filename, mode: 'r')
6
6
  Converter.new(source).convert
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tex2id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-06 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler