tex2id 1.4.0 → 1.6.0
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/tex2id/cli.rb +4 -9
- data/lib/tex2id/converter/constants.rb +1 -0
- data/lib/tex2id/converter.rb +2 -21
- data/lib/tex2id/version.rb +1 -1
- data/lib/tex2id.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5476eb432da2d0c6cc135bd2da0b1eb491cca009cedb50cebab2d080a364ab10
|
4
|
+
data.tar.gz: 87a8fe6641b5af03bca1a94971c41cda500babee9a275b5585a157b73935f1fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
55
|
+
File.open(output_file, 'w')
|
57
56
|
else
|
58
|
-
$stdout
|
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:>',
|
data/lib/tex2id/converter.rb
CHANGED
@@ -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 =
|
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
|
42
|
+
line.gsub!(/<CharStyle:(?:コマンド|コード(文字単位))>[^<]+<CharStyle:>/) do |matched|
|
62
43
|
id = inline_commands.length
|
63
44
|
inline_commands << matched
|
64
45
|
"<tex2id_inline_commands[#{id}]>"
|
data/lib/tex2id/version.rb
CHANGED
data/lib/tex2id.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|