-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjnl_jats2html
48 lines (39 loc) · 1.2 KB
/
jnl_jats2html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'ostruct'
# Process the script parameters.
options = OpenStruct.new
options.gen_html = false
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename(__FILE__)} jats_file [jats_file...]"
opts.on_tail('-h', '--help', 'Print this help message') do
puts opts
exit 0
end
end
option_parser.parse!(ARGV)
if ARGV.count < 1
puts option_parser.help
return
end
# Determine the root directory of the code base.
script_dir = File.expand_path(File.dirname(__FILE__))
root_dir = File.dirname(script_dir)
jats_file_list = ARGV
require 'uri'
require_relative File.join(root_dir, 'lib', 'xslt')
jats2html_xsl_file = File.join(root_dir, "lib", "journal", "xsl", "janeway", "janeway.xsl")
jats_file_list.each do |jats_file|
jats_file = File.expand_path(jats_file)
if !File.file?(jats_file)
puts "Error: invalid file #{jats_file}"
next
end
html_file = File.join(File.dirname(jats_file), File.basename(jats_file, ".*") + ".html")
UMPTG::XSLT.transform(
:xslpath => jats2html_xsl_file,
:srcpath => jats_file,
:destpath => html_file
)
end