aozora2html 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/bin/aozora2html +30 -2
- data/lib/aozora2html/version.rb +1 -1
- data/lib/embed_gaiji_tag.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 840a166919aa955cec4bdead0375f761d51f9786
|
4
|
+
data.tar.gz: 5137110c4416f5b63b259f04ba61a7e02d4e4114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e30c970ee45ee0a7394541fcfe0d0223cf0e1b36b58aec2c662f3967a442f75e88eb31e78e3bf6c78d917a49b1e6f915420bd5f25307dc91c53e72ab35cb762e
|
7
|
+
data.tar.gz: 3fbcd4e47edfaa127670a72825267943503f8379899cc83cdfb4e8504f48dd1fe0f8cc347d4f2d9b3c9fd09eab793eec473fc3fe9dcad03d7d677dfb7779b424
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Aozora2Html
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/aozorahack/aozora2html.svg?branch=master)](https://travis-ci.org/aozorahack/aozora2html) [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html)
|
3
|
+
[![Build Status](https://travis-ci.org/aozorahack/aozora2html.svg?branch=master)](https://travis-ci.org/aozorahack/aozora2html) [![Gem Version](https://badge.fury.io/rb/aozora2html.svg)](https://badge.fury.io/rb/aozora2html) [![Code Climate](https://codeclimate.com/github/aozorahack/aozora2html/badges/gpa.svg)](https://codeclimate.com/github/aozorahack/aozora2html)
|
4
4
|
|
5
5
|
青空文庫の「組版案内」( http://kumihan.aozora.gr.jp/ )で配布されているtxt2html内にあるt2hs.rbを改造するプロジェクトです。
|
6
6
|
|
data/bin/aozora2html
CHANGED
@@ -26,11 +26,35 @@ class Aozora2Html
|
|
26
26
|
push_char(obj)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
def dispatch_gaiji
|
31
|
+
hook = @stream.peek_char(0)
|
32
|
+
if hook == "[".encode("shift_jis")
|
33
|
+
read_char
|
34
|
+
# embed?
|
35
|
+
command,raw = read_to_nest("]".encode("shift_jis"))
|
36
|
+
try_emb = kuten2png(command)
|
37
|
+
if try_emb != command
|
38
|
+
try_emb
|
39
|
+
elsif command.match(/U\+([0-9A-F]{4,5})/)
|
40
|
+
unicode_num = $1
|
41
|
+
ch = Embed_Gaiji_tag.new(self, nil, nil, command)
|
42
|
+
ch.unicode = unicode_num
|
43
|
+
ch
|
44
|
+
else
|
45
|
+
# Unemb
|
46
|
+
escape_gaiji(command)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
"※"
|
50
|
+
end
|
51
|
+
end
|
29
52
|
end
|
30
53
|
|
31
54
|
opt = OptionParser.new("Usage: aozora2html [options] <text file> [<html file>]\n")
|
32
55
|
opt.on('--gaiji-dir DIR', 'setting gaiji directory')
|
33
|
-
opt.on('--use-jisx0213', '
|
56
|
+
opt.on('--use-jisx0213', 'use JIS X 0213 character')
|
57
|
+
opt.on('--use-unicode', 'use Unicode character')
|
34
58
|
opt.version = Aozora2Html::VERSION
|
35
59
|
options = opt.getopts
|
36
60
|
|
@@ -43,6 +67,10 @@ if options["use-jisx0213"]
|
|
43
67
|
Accent_tag.use_jisx0213 = true
|
44
68
|
end
|
45
69
|
|
70
|
+
if options["use-unicode"]
|
71
|
+
Embed_Gaiji_tag.use_unicode = true
|
72
|
+
end
|
73
|
+
|
46
74
|
if ARGV.size < 1 || ARGV.size > 2
|
47
75
|
$stderr.print opt.banner
|
48
76
|
exit 1
|
@@ -68,7 +96,7 @@ Dir.mktmpdir do |dir|
|
|
68
96
|
exit 1
|
69
97
|
end
|
70
98
|
else
|
71
|
-
if !File.
|
99
|
+
if !File.exist?(src_file)
|
72
100
|
$stderr.print "file not found: #{src_file}\n"
|
73
101
|
exit 1
|
74
102
|
end
|
data/lib/aozora2html/version.rb
CHANGED
data/lib/embed_gaiji_tag.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class Embed_Gaiji_tag
|
2
2
|
alias_method :to_s_orig, :to_s
|
3
|
+
attr_accessor :unicode
|
3
4
|
|
4
5
|
def self.use_jisx0213=(val)
|
5
6
|
@use_jisx0213 = val
|
@@ -9,13 +10,23 @@ class Embed_Gaiji_tag
|
|
9
10
|
@use_jisx0213
|
10
11
|
end
|
11
12
|
|
13
|
+
def self.use_unicode=(val)
|
14
|
+
@use_unicode = val
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.use_unicode
|
18
|
+
@use_unicode
|
19
|
+
end
|
20
|
+
|
12
21
|
def jisx0213_to_unicode(code)
|
13
22
|
Aozora2Html::JIS2UCS[code]
|
14
23
|
end
|
15
24
|
|
16
25
|
def to_s
|
17
|
-
if Embed_Gaiji_tag.use_jisx0213
|
26
|
+
if Embed_Gaiji_tag.use_jisx0213 && @code
|
18
27
|
jisx0213_to_unicode(@code.to_sym)
|
28
|
+
elsif Embed_Gaiji_tag.use_unicode && @unicode
|
29
|
+
'&#x'+@unicode+';'
|
19
30
|
else
|
20
31
|
to_s_orig
|
21
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aozora2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aozorahack team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|