houcluttex 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 829d946b580113b2b827909a19c48cf232b6073d5967d670503b5d779826ed61
4
+ data.tar.gz: 7b76686faba0bf7641673f9518afc0ee1aa49541bf524d15df216698221dd5f8
5
+ SHA512:
6
+ metadata.gz: 4076b9d9a540042ceeb2a3393cb9adb0b53630644229fd5b6ab91196149cfc9ff9f664e14ce708de97db752690492665dda07c8b21a36e74c9ddc2f951cd3de6
7
+ data.tar.gz: 98d5467b4273daf468eba8e8322fc7774cf2fa153742f3027f1ffeccc03945f892e7451eed376c0b5676af98d89ba4ec3cc8bce323af21117133bf76651e2110
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ Gemfile.lock
11
+ .DS_Store
12
+
13
+ sample/**/*.pdf
14
+ sample/**/*.synctex.gz
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in houcluttex.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Ishotihadus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # houcluttex: 放課後クライマックス ClutTeX ガールズ
2
+
3
+ コンフィグファイルやマジックコメントからのコンフィグを利用して [ClutTeX](https://github.com/minoki/cluttex/) を実行するツールです。
4
+
5
+ ## インストール
6
+
7
+ $ gem install houcluttex
8
+
9
+ ## 使い方
10
+
11
+ $ cluttex [OPTIONS] [--] INPUT.tex
12
+
13
+ ### コンフィグ
14
+
15
+ コンフィグは、次の 3 通りで指定できます。下のオプションが優先されます。
16
+
17
+ - コンフィグファイル(`houcluttex.yml`)
18
+ - マジックコメント
19
+ - コマンドラインオプション
20
+
21
+ #### コンフィグファイル
22
+
23
+ yaml 形式で指定します。`houcluttex.yml` をデフォルトとしますが、`houcluttex.yaml`、`houcluttexrc`、`.houcluttexrc` なども可能です。
24
+ コマンドラインオプション `--config` でファイル名を指定できます。
25
+
26
+ yaml ファイルは Key-value の形式で ClutTeX のオプションを指定します。
27
+
28
+ ```houcluttex.yml
29
+ engine: uplatex
30
+ bibtex: upbibtex
31
+ shell-escape: true
32
+ synctex: 1
33
+ file-line-error: true
34
+ halt-on-error: false
35
+ ```
36
+
37
+ #### マジックコメント
38
+
39
+ [atom-latex](https://github.com/thomasjo/atom-latex/wiki/Overridding-Build-Settings) のようなマジックコメントを使うことができます。
40
+
41
+ 対応しているのは次のオプションです。
42
+
43
+ - `root`
44
+ - `engine` / `program`
45
+ - `synctex`
46
+ - `jobname`
47
+ - `makeindex`
48
+ - `bibtex`
49
+ - `format` / `outputFormat`
50
+ - `outputDirectory`
51
+ - `enableSynctex`
52
+ - `enableShellEscape`
53
+
54
+ `root` オプションは、入力ファイル(`input` オプションの値)を再帰的に `root` オプションで指定されたファイルに書き換えます。
55
+
56
+ #### コマンドラインオプション
57
+
58
+ ClutTeX と同様のコマンドラインオプションと、`config` オプション、`cluttex-path` オプションが利用できます。
59
+
60
+ #### 特別なオプション
61
+
62
+ `input` オプションで指定したファイル名は、入力ファイルがコマンドラインで与えられなかった場合の入力ファイルとして利用します。
63
+ このオプションはコマンドラインでは利用できません。
64
+
65
+ `cluttex-path` オプションは ClutTeX のパスを指定します。デフォルトは `cluttex` です。
66
+
67
+ ## ライセンス
68
+
69
+ この gem は [MIT License](https://opensource.org/licenses/MIT) のもとで利用できます。
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'houcluttex'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/houcluttex ADDED
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'fileutils'
5
+ require 'shellwords'
6
+ require 'yaml'
7
+
8
+ def convert_bool(str)
9
+ case str.downcase
10
+ when 'yes', 'true'
11
+ true
12
+ when 'no', 'false'
13
+ false
14
+ end
15
+ end
16
+
17
+ config = {
18
+ 'cluttex-path' => nil,
19
+ 'input' => nil,
20
+
21
+ 'engine' => nil,
22
+ 'output' => nil,
23
+ 'fresh' => false,
24
+ 'max-iterations' => 3,
25
+ 'change-directory' => false,
26
+ 'watch' => false,
27
+ 'color' => 'auto',
28
+ 'includeonly' => nil,
29
+ 'make-depends' => nil,
30
+ 'tex-option' => [],
31
+ 'dvipdfmx-option' => [],
32
+ 'verbose' => false,
33
+
34
+ 'makeindex' => nil,
35
+ 'bibtex' => nil,
36
+ 'biber' => nil,
37
+ 'makeglossaries' => nil,
38
+
39
+ 'shell-escape' => true,
40
+ 'shell-restricted' => false,
41
+ 'synctex' => nil,
42
+ 'file-line-error' => true,
43
+ 'halt-on-error' => true,
44
+ 'interaction' => 'nonstopmode',
45
+ 'jobname' => nil,
46
+ 'fmt' => nil,
47
+ 'output-directory' => nil,
48
+ 'output-format' => 'pdf'
49
+ }
50
+
51
+ config_file = ['houcluttex.yml', 'houcluttex.yaml', 'houcluttex_config.yml', 'houcluttex_config.yaml', 'houcluttexrc', '.houcluttexrc'].find{|e| File.exist?(e)}
52
+
53
+ # parse command-line options
54
+
55
+ argv = ARGV.dup
56
+ config_by_args = {}
57
+ remain_args = []
58
+
59
+ until argv.empty?
60
+ arg = argv.shift
61
+ if arg == '--'
62
+ remain_args += argv
63
+ argv = []
64
+ elsif arg.start_with?('--')
65
+ m = arg.match(/\A--([^=]+)(=(.*))?\z/)
66
+ case m[1]
67
+ when 'fresh', 'change-directory', 'watch', 'verbose', 'shell-escape', 'shell-restricted', 'file-line-error', 'halt-on-error'
68
+ config_by_args[m[1]] = true
69
+ when 'no-change-directory', 'no-shell-escape', 'no-file-line-error', 'no-halt-on-error'
70
+ config_by_args[m[1][3..-1]] = false
71
+ when 'tex-options', 'dvipdfmx-options'
72
+ config_by_args[m[1][0..-2]] ||= []
73
+ config_by_args[m[1][0..-2]] += Shellwords.split(m[3] || argv.shift)
74
+ when 'tex-option', 'dvipdfmx-option'
75
+ config_by_args[m[1]] ||= []
76
+ config_by_args[m[1]] << (m[3] || argv.shift)
77
+ when 'input'
78
+ raise 'cannot use `--input` option in command-line'
79
+ when 'config'
80
+ config_file = m[3] || argv.shift
81
+ else
82
+ config_by_args[m[1]] = m[3] || argv.shift
83
+ end
84
+ elsif arg.start_with?('-')
85
+ case arg
86
+ when '-e'
87
+ config_by_args['engine'] = argv.shift
88
+ when '-o'
89
+ config_by_args['output'] = argv.shift
90
+ when '-V'
91
+ config_by_args['verbose'] = true
92
+ else
93
+ warn "option `#{arg}` is ignored"
94
+ end
95
+ else
96
+ remain_args << arg
97
+ end
98
+ end
99
+
100
+ # load yaml
101
+ config.merge!(YAML.load_file(config_file)) if config_file
102
+
103
+ # decide input file
104
+ raise 'multiple input files' if remain_args.size >= 2
105
+ config['input'] = remain_args.first unless remain_args.empty?
106
+ raise 'no input file' if config['input'].nil?
107
+
108
+ # parse magic comments
109
+
110
+ loop do
111
+ raise "input file `#{config['input']}` does not exist" unless File.exist?(config['input'])
112
+
113
+ root_file = nil
114
+ File.foreach(config['input']) do |line|
115
+ next if line.strip.empty?
116
+ break unless line[0] == '%'
117
+ m = line.match(/^%\s*!TEX (\S+)\s*=\s*(.*?)\s*$/)
118
+ next unless m
119
+ key = m[1].tr('_-', '').downcase
120
+ value = m[2]
121
+ case key
122
+ when 'root'
123
+ root_file = value
124
+ when 'engine', 'synctex', 'jobname', 'makeindex', 'bibtex'
125
+ config[key] = value
126
+ when 'program'
127
+ config['engine'] = value
128
+ when 'format', 'outputformat'
129
+ config['output-format'] = value
130
+ when 'outputdirectory'
131
+ config['output-directory'] = value
132
+ when 'enablesynctex'
133
+ value = convert_bool(value)
134
+ raise 'magic option `enableSynctex` must be boolean' if value.nil?
135
+ config['synctex'] = value ? (config['synctex'] || 1) : nil
136
+ when 'enableshellescape'
137
+ value = convert_bool(value)
138
+ raise 'magic option `enableShellEscape` must be boolean' if value.nil?
139
+ config['shell-escape'] = value
140
+ else
141
+ warn "magic comment `#{m[1]}` is ignored"
142
+ end
143
+ end
144
+ break if root_file.nil? || config['input'] == root_file
145
+ config['input'] = root_file
146
+ end
147
+
148
+ # merge config
149
+ config.merge!(config_by_args)
150
+
151
+ # specify command
152
+ config['cluttex-path'] ||= 'cluttex'
153
+ `type #{config['cluttex-path']} 2>&1`
154
+ raise "command `#{config['cluttex-path']}` not found" unless $?.success?
155
+
156
+ if config['verbose']
157
+ warn 'ClutTeX options:'
158
+ config.each do |k, v|
159
+ warn " #{k}: #{v.inspect}"
160
+ end
161
+ end
162
+
163
+ # generate command
164
+
165
+ cmd_args = []
166
+
167
+ config.each do |k, v|
168
+ case k
169
+ when 'cluttex-path', 'input'
170
+ # ignore
171
+ when 'tex-option', 'dvipdfmx-option'
172
+ v.each{|e| cmd_args << "--#{k}=#{e}"}
173
+ when 'includeonly'
174
+ cmd_args << (v.is_a?(Array) ? "--#{k}=#{v.join(',')}" : "--#{k}=#{v}") if v
175
+ when 'fresh', 'watch', 'verbose', 'shell-restricted'
176
+ cmd_args << "--#{k}" if v
177
+ when 'change-directory', 'shell-escape', 'file-line-error', 'halt-on-error'
178
+ cmd_args << (v ? "--#{k}" : "--no-#{k}")
179
+ else
180
+ cmd_args << "--#{k}=#{v}" unless v.nil?
181
+ end
182
+ end
183
+
184
+ cmd_args << '--'
185
+ cmd_args << config['input']
186
+
187
+ FileUtils.mkdir_p(config['output-directory']) if config['output-directory']
188
+
189
+ system(config['cluttex-path'], *cmd_args)
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $:.unshift(lib) unless $:.include?(lib)
5
+ require 'houcluttex/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'houcluttex'
9
+ spec.version = Houcluttex::VERSION
10
+ spec.authors = ['Ishotihadus']
11
+ spec.email = ['hanachan.pao@gmail.com']
12
+
13
+ spec.summary = 'configurable cluttex wrapper'
14
+ spec.description = 'configurable cluttex wrapper'
15
+ spec.homepage = 'https://github.com/ishotihadus/houcluttex'
16
+ spec.license = 'MIT'
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject{|f| f.match(%r{^(test|spec|features)/})}
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}){|f| File.basename(f)}
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.add_development_dependency 'bundler'
28
+ spec.add_development_dependency 'rake'
29
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Houcluttex
4
+ VERSION = '1.0.0'
5
+ end
data/lib/houcluttex.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "houcluttex/version"
2
+
3
+ module Houcluttex
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,7 @@
1
+ @inproceedings{testcite,
2
+ author = {Kasuga, Mirai and Yabuki, Kana and Tanaka, Kotoha},
3
+ booktitle = {THE IDOLM@STER MILLION THE@TER GENERATION 17 STAR ELEMENTS},
4
+ pages = {1--7},
5
+ title = {Episode. {T}iara},
6
+ year = {2019}
7
+ }
@@ -0,0 +1,15 @@
1
+ % !TEX engine = uplatex
2
+ % !TEX enableSynctex = true
3
+ % !TEX enableShellEscape = true
4
+ % !TEX bibtex = upbibtex
5
+
6
+ \documentclass[uplatex]{jsarticle}
7
+ \bibliographystyle{plain}
8
+
9
+ \begin{document}
10
+
11
+ 本気はレプリカじゃない だからそれぞれ 立ち向かうべき 今日があるって\cite{testcite}
12
+
13
+ \bibliography{test}
14
+
15
+ \end{document}
@@ -0,0 +1,7 @@
1
+ engine: uplatex
2
+ bibtex: upbibtex
3
+ shell-escape: true
4
+ synctex: 1
5
+ file-line-error: true
6
+ halt-on-error: false
7
+ input: test.tex
@@ -0,0 +1,7 @@
1
+ @inproceedings{testcite,
2
+ author = {Kasuga, Mirai and Yabuki, Kana and Tanaka, Kotoha},
3
+ booktitle = {THE IDOLM@STER MILLION THE@TER GENERATION 17 STAR ELEMENTS},
4
+ pages = {1--7},
5
+ title = {Episode. {T}iara},
6
+ year = {2019}
7
+ }
@@ -0,0 +1,10 @@
1
+ \documentclass[uplatex]{jsarticle}
2
+ \bibliographystyle{plain}
3
+
4
+ \begin{document}
5
+
6
+ 本気はレプリカじゃない だからそれぞれ 立ち向かうべき 今日があるって\cite{testcite}
7
+
8
+ \bibliography{test}
9
+
10
+ \end{document}
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: houcluttex
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ishotihadus
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: configurable cluttex wrapper
42
+ email:
43
+ - hanachan.pao@gmail.com
44
+ executables:
45
+ - houcluttex
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - exe/houcluttex
57
+ - houcluttex.gemspec
58
+ - lib/houcluttex.rb
59
+ - lib/houcluttex/version.rb
60
+ - sample/magic/test.bib
61
+ - sample/magic/test.tex
62
+ - sample/yaml/houcluttex.yml
63
+ - sample/yaml/test.bib
64
+ - sample/yaml/test.tex
65
+ homepage: https://github.com/ishotihadus/houcluttex
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubygems_version: 3.0.1
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: configurable cluttex wrapper
88
+ test_files: []