Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a commandline parameter to specify CSS file(s) #14

Merged
merged 1 commit into from
Mar 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion bin/aozora2html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ end

opt = OptionParser.new("Usage: aozora2html [options] <text file> [<html file>]\n")
opt.on('--gaiji-dir DIR', 'setting gaiji directory')
opt.on('--css-files FILES', 'setting css directory')
opt.on('--use-jisx0213', 'use JIS X 0213 character')
opt.on('--use-unicode', 'use Unicode character')
opt.version = Aozora2Html::VERSION
Expand All @@ -62,6 +63,10 @@ if options["gaiji-dir"]
$gaiji_dir = options["gaiji-dir"]
end

if options["css-files"]
$css_files = options["css-files"].split(",")
end

if options["use-jisx0213"]
Embed_Gaiji_tag.use_jisx0213 = true
Accent_tag.use_jisx0213 = true
Expand Down Expand Up @@ -114,4 +119,3 @@ Dir.mktmpdir do |dir|
print output
end
end

8 changes: 7 additions & 1 deletion lib/t2hs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

$gaiji_dir = "../../../gaiji/"

$css_files = Array["../../aozora.css"]

# 1.8 like to_s method to Array
class Array
def to_s
Expand Down Expand Up @@ -1157,7 +1159,11 @@ def process_header()
html_title += "</title>"

# �o��
@out.print("<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\r\n \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" >\r\n<head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html;charset=Shift_JIS\" />\r\n <meta http-equiv=\"content-style-type\" content=\"text/css\" />\r\n <link rel=\"stylesheet\" type=\"text/css\" href=\"../../aozora.css\" />\r\n\t#{html_title}\r\n <script type=\"text/javascript\" src=\"../../jquery-1.4.2.min.js\"></script>\r\n <link rel=\"Schema.DC\" href=\"http://purl.org/dc/elements/1.1/\" />\r\n <meta name=\"DC.Title\" content=\"#{header_info[:title]}\" />\r\n <meta name=\"DC.Creator\" content=\"#{header_info[:author]}\" />\r\n <meta name=\"DC.Publisher\" content=\"�‹󕶌�\" />\r\n</head>\r\n<body>\r\n<div class=\"metadata\">\r\n")
@out.print("<?xml version=\"1.0\" encoding=\"Shift_JIS\"?>\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\r\n \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"ja\" >\r\n<head>\r\n <meta http-equiv=\"Content-Type\" content=\"text/html;charset=Shift_JIS\" />\r\n <meta http-equiv=\"content-style-type\" content=\"text/css\" />\r\n")
$css_files.each{|css|
@out.print("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"" + css + "\" />\r\n")
}
@out.print("\t#{html_title}\r\n <script type=\"text/javascript\" src=\"../../jquery-1.4.2.min.js\"></script>\r\n <link rel=\"Schema.DC\" href=\"http://purl.org/dc/elements/1.1/\" />\r\n <meta name=\"DC.Title\" content=\"#{header_info[:title]}\" />\r\n <meta name=\"DC.Creator\" content=\"#{header_info[:author]}\" />\r\n <meta name=\"DC.Publisher\" content=\"�‹󕶌�\" />\r\n</head>\r\n<body>\r\n<div class=\"metadata\">\r\n")
@out.print("<h1 class=\"title\">#{header_info[:title]}</h1>\r\n")
out_header_info(header_info, :original_title)
out_header_info(header_info, :subtitle)
Expand Down