aozora2html 0.5.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5986973cf323ca85a48b74c8537a0c43ff4c9b5
4
- data.tar.gz: ed11bf0bffd8773090e0c336e9d25818156e42ff
3
+ metadata.gz: 840a166919aa955cec4bdead0375f761d51f9786
4
+ data.tar.gz: 5137110c4416f5b63b259f04ba61a7e02d4e4114
5
5
  SHA512:
6
- metadata.gz: 303a38cddb21e188905acc4e2e537582d9f621415ffa460964dfd775484113b435a1cba103d7c9612c5a5773e3cdd48bd8162c1ca3d7a25b7e9436a09d4e6dc3
7
- data.tar.gz: 0b5ce96681fb726ad975d7926e78c203b5dc9001f652b3f43fa09ea9b9b590143f55438fd038ce3bdc96800501a7c02de83a01f603aee86fc9b3a15005608abd
6
+ metadata.gz: e30c970ee45ee0a7394541fcfe0d0223cf0e1b36b58aec2c662f3967a442f75e88eb31e78e3bf6c78d917a49b1e6f915420bd5f25307dc91c53e72ab35cb762e
7
+ data.tar.gz: 3fbcd4e47edfaa127670a72825267943503f8379899cc83cdfb4e8504f48dd1fe0f8cc347d4f2d9b3c9fd09eab793eec473fc3fe9dcad03d7d677dfb7779b424
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ <a name="0.6.0"></a>
2
+ ## 0.6.0
3
+
4
+ ### Bug Fixes
5
+
6
+ * helpメッセージを修正した
7
+
8
+ ### Features
9
+
10
+ * `--use-unicode`オプションでU+XXXX表記も数値実体参照として表示できるようにした
11
+ * Code Climateを導入して警告が出た部分を一部修正した
12
+
1
13
  <a name="0.5.0"></a>
2
14
  ## 0.5.0
3
15
 
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', 'setting gaiji directory')
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.exists?(src_file)
99
+ if !File.exist?(src_file)
72
100
  $stderr.print "file not found: #{src_file}\n"
73
101
  exit 1
74
102
  end
@@ -1,3 +1,3 @@
1
1
  class Aozora2Html
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -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.5.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-07 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip