raf2html 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c0f881fc66a26aebd0b0dd0409b158bcd891da1
4
- data.tar.gz: a2d16367519ffd3ba72505b4f2220763b2f9b860
3
+ metadata.gz: a919fa589de9a092cfc4d6b7e4b1a4d85df8cdb8
4
+ data.tar.gz: c4285b4b83fccbb44060bdf0d2658df06fa8792c
5
5
  SHA512:
6
- metadata.gz: 7bbe06c4e3caeccc441150fce387eb5e4a3beee77df5651813a766d378b2986b75a5ad7554cfb6894dd2c35611fa968428a2f7234e4245a8e08d0fea0a8a6a4b
7
- data.tar.gz: 29930453f32b03224af31b5b0b403008269cca3a032489acff4c1812f0284c4a243fb471994d8eab27122f53449df17dbfd604124d21ecf6649a7838f160734a
6
+ metadata.gz: 163ae6e6b0b468e5d03ed5cd6e870979908f2298f36a802ce4046f303a45aa5ee6b8a923522c242799eb98d0210605a2ab20a0f4aa833ddcb66de2add86ebd2b
7
+ data.tar.gz: b3409ac7fce9355ba030cf9ffd176d06c29a015b4cd61cfae67b5a87de7c1b333f7fc63e848404d671d0c76bb2d7e6d57a067b72fd384f13ebd96ead390779ff
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- raf2html (0.0.7)
5
- raf-parser (>= 0.2.2)
4
+ raf2html (0.0.8)
5
+ raf-parser (>= 0.2.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- raf-parser (0.2.2)
10
+ mimemagic (0.2.1)
11
+ raf-parser (0.2.3)
12
+ mimemagic
11
13
  rake (10.1.0)
12
14
 
13
15
  PLATFORMS
@@ -1,3 +1,19 @@
1
+ == 0.0.8 (2013-12-10)
2
+ * new: Reference の 拡張子書式(.%) に対応(@options[:extension])
3
+ * new: LabelLink エレメントに対応
4
+ * new: エレメント(タグ)をカスタマイズできる機能を追加
5
+ * new: スタイルシート指定のオプション(--css)にショートネーム(-c)を追加
6
+ * new: javascript を読み込むコマンドラインオプションを追加
7
+ * new: Quote クラスに出力に google prettify のコードを追加
8
+ * change: IMAGE エレメントを廃止して、MEDIA エレメントに対応
9
+ * change: メタデータの項目を変更
10
+ * change: manuedo の出力フォーマットを変更
11
+ * change: css, javascript, custom_element オプションのデフォルト値を nil から ""(empty) に変更
12
+ * fix: Label エレメントのリンクが name ではなく href になっていたのを修正
13
+
14
+ == 0.0.7 (2013-12-05)
15
+ * Variable に対応
16
+
1
17
  == 0.0.6 (2013-12-05)
2
18
  * 設定ファイル(~/.raf2html.yaml)を追加
3
19
 
@@ -1,27 +1,32 @@
1
1
  = raf2html
2
- "raf2html" is raf(simple document format) convert to HTML format.
3
- refer to : http://garin.jp/doc/raf/raf (this page is japanese)
2
+ "raf2html" is raf document convert to HTML.
4
3
 
5
- == INSTALLATION
6
- // check ruby version
7
- $ ruby -v
8
- ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
4
+ == Require
5
+ * ruby-2.0.0p353 or later
9
6
 
10
- // raf2html gem package install
7
+ == Installation
8
+ // package install
11
9
  $ gem install raf2html
12
10
 
13
- == UTILITIES
14
- === raf2html
15
- raf format to HTML format conveter.
11
+ == Getting Started
12
+ === Edit raf document
16
13
 
17
- + Usage
18
- // edit
19
14
  $ vi mydoc.raf
20
15
  = This is My document
21
16
  raf is simple document format.
22
17
 
23
- // to html
24
- $ raf2html mydoc.raf > mydoc.html
18
+ format manutal : http://garin.jp/doc/raf/raf (this page is japanese)
19
+
20
+ === to HTML
21
+ $ raf2html mydoc.raf
22
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
23
+ ...
24
+ <h1>This is My document</h1> ...
25
+ <p>raf is simple document format.<br /></p>
26
+ ...
27
+
28
+ === Print Help
29
+ $ raf2html --help
25
30
 
26
31
  == Read more
27
32
  Official Web Site : http://garin.jp/doc/raf/raf (this page is japanese)
data/RELEASE CHANGED
@@ -1 +1 @@
1
- 2013-12-04
1
+ 2013-12-10
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -12,7 +12,7 @@ CONFIG_FILE="~/.raf2html.yaml"
12
12
  config_file_path = File.expand_path(CONFIG_FILE)
13
13
 
14
14
  # デフォルトの設定値
15
- options = {:css => nil, :language => 'ja', :index => true, :quiet => false}
15
+ options = {:css => "", :js => "", :extension => '.html', :media_directory => "", :custom_element => "" , :language => 'ja', :index => true, :quiet => false}
16
16
 
17
17
  # 設定ファイルの読み込み
18
18
  if File.exist?(config_file_path)
@@ -35,11 +35,19 @@ opt = OptionParser.new do |opt|
35
35
  opt.banner = "Usage: raf2html [options] file"
36
36
  opt.version = Raf::Raf2Html::VERSION
37
37
  opt.release = Raf::Raf2Html::RELEASE
38
- opt.on("--css file", "スタイルシートのファイルを指定") {|f| options[:css] = f}
38
+ opt.on("-c", "--css file", "HTMLに埋め込むスタイルシートを指定") {|f| options[:css] = f}
39
+ opt.on("-j", "--javascript file", "HTMLに埋め込むJavaScriptを指定") {|f| options[:js] = f}
39
40
  opt.on("-L", "--language LANG", "言語(デフォルトは #{options[:language]} 。ドキュメント側で指定されていればそちらを優先)"){|l| options[:language] = l}
40
41
  opt.on("--[no-]index", "目次を生成する(デフォルトは生成する)"){|v| options[:index] = v }
41
42
  opt.on("--[no-]metadata", "メタ情報を出力しない(デフォルトは出力する)"){|v| options[:metadata] = v }
42
43
  opt.on("-q","--quiet", "本文だけを出力する(ヘッダやフッタは出力しない)"){ options[:quiet] = true }
44
+ opt.on("-s","--extension string", "リファレンス記法で「.%」を置換する拡張子(デフォルト .html)"){|s| options[:extension] = s }
45
+ opt.on("-m", "--media_directory directory", "画像や動画などのメディアファイルを配置する基底ディレクトリ"){|d| options[:media_directory] = d }
46
+ opt.on("--custom_element file", "HTMLタグをカスタマイズするためのRubyファイル)"){|f| options[:custom_element] = f }
47
+ opt.on("-V","--parser-version", "使用する raf-parser のバージョンを表示"){
48
+ puts "raf-parser: #{Raf::VERSION} (#{Raf::RELEASE})"
49
+ exit 0
50
+ }
43
51
  end
44
52
  opt.parse!(ARGV)
45
53
  usage(opt) unless ARGV[0]
@@ -13,17 +13,24 @@ module Raf
13
13
  @debug = true
14
14
 
15
15
  # options
16
- @css = File.open(File.expand_path(options[:css])).readlines.to_s unless options[:css].nil?
16
+ @css = File.open(File.expand_path(options[:css])).readlines.to_s unless options[:css].empty?
17
+ @js = File.open(File.expand_path(options[:js])).readlines.to_s unless options[:js].empty?
17
18
  @language = options[:language]
18
19
  @index = options[:index]
19
20
  @metadata = options[:metadata]
20
21
  @quiet = options[:quiet]
21
22
 
22
- @raf = BlockParser.new
23
+ get_customized_element(options[:custom_element]) unless options[:custom_element].empty?
24
+ @raf = BlockParser.new(options)
23
25
  @metadata = setup_metadata
24
26
  @nodes = @raf.parse src
25
27
  end
26
28
 
29
+ # エレメントのカスタム用ファイルを読み込む
30
+ def get_customized_element(file)
31
+ require File.expand_path(file)
32
+ end
33
+
27
34
  def setup_metadata
28
35
  metadata = @raf.metadata
29
36
  metadata[:language] = @language if metadata[:language].nil?
@@ -54,7 +61,7 @@ module Raf
54
61
  next if h[:level] == 1 or h[:level] == 6
55
62
 
56
63
  if h[:level] == 5
57
- str += "<div class=><a href='#raf-head#{h[:level]}-#{i+1}'><span class='space' />#{h[:title]}</a></div>\n"
64
+ str += %[<div class="nonum"><a href="#raf-head#{h[:level]}-#{i+1}"><span class="space" />#{h[:title]}</a></div>\n]
58
65
  else
59
66
  str += index_terminate(h[:level], level_pre)
60
67
  str += "<li><a href='#raf-head#{h[:level]}-#{i+1}'>#{h[:index]}#{h[:title]}</a>\n"
@@ -87,7 +94,7 @@ module Raf
87
94
  str = "<div id='raf-metadata'>"
88
95
  str += %[<div>#{CGI.escapeHTML(@metadata[:description])}</div>] unless @metadata[:description].nil?
89
96
  str += %[<ul class="list-inline">]
90
- %w{ creator date update publisher version contributer revision tag }.each do |m|
97
+ %w{ author create update publisher version tag }.each do |m|
91
98
  str += %[<li><strong>#{m}</strong>:#{CGI.escapeHTML(@metadata[m.to_sym])}</li>] unless @metadata[m.to_sym].nil?
92
99
  end
93
100
  str += "</ul>"
@@ -116,6 +123,7 @@ module Raf
116
123
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
117
124
  EOL
118
125
  str += css
126
+ str += javascript
119
127
  str += <<EOL
120
128
  <title>#{@metadata[:subject]}</title>
121
129
  </head>
@@ -128,13 +136,14 @@ EOL
128
136
  end
129
137
 
130
138
  def css
131
- # str = <<EOL
132
- #<link href="screen.css" rel="stylesheet" type="text/css" media="screen" />
133
- #<link href="handheld.css" rel="stylesheet" type="text/css" media="handheld" />
134
- #<link href="print.css" rel="stylesheet" type="text/css" media="print" />
135
- #EOL
136
139
  str = ""
137
- str += %%<style type="text/css"><!--\n#{@css}\n--></style>\n% unless @css.nil?
140
+ str += %[<style type="text/css"><!--\n#{@css}\n--></style>\n] unless @css.nil?
141
+ str
142
+ end
143
+
144
+ def javascript
145
+ str = ""
146
+ str += %[<script type="text/javascript">#{@js}</script>\n] unless @js.nil?
138
147
  str
139
148
  end
140
149
 
@@ -54,7 +54,7 @@ module Raf
54
54
 
55
55
  class Quote < Element
56
56
  def apply
57
- "<pre>#{CGI.escapeHTML(@contents.join)}</pre>\n"
57
+ %[<pre class="prettyprint linenums">#{CGI.escapeHTML(@contents.join)}</pre>\n]
58
58
  end
59
59
  end
60
60
 
@@ -136,7 +136,14 @@ module Raf
136
136
  class Label < Element
137
137
  # @contents = [label, title]
138
138
  def apply
139
- "<a href='##{@contents[0]}' id='#{@contents[0]}'>#{@contents[1]}</a>"
139
+ %[<a name="#{@contents[0]}" id="#{@contents[0]}">#{@contents[1]}</a>]
140
+ end
141
+ end
142
+
143
+ class LabelLink < Element
144
+ # @contents = [label, title]
145
+ def apply
146
+ %[<a href="##{@contents[0]}">#{@contents[1]}</a>]
140
147
  end
141
148
  end
142
149
 
@@ -185,7 +192,7 @@ module Raf
185
192
 
186
193
  class Manuedo < Element
187
194
  def apply
188
- "<span class='manuedo'>/#{@contents.map{|c| c.apply}}/</span>"
195
+ %{<span class="manuedo">[#{@contents.map{|c| c.apply}}]</span>}
189
196
  end
190
197
  end
191
198
  class Ruby < Element
@@ -205,9 +212,19 @@ module Raf
205
212
  end
206
213
  end
207
214
 
208
- class Image < Element
215
+ class Media < Element
209
216
  def apply
210
- "<img src='#{@contents}' />"
217
+ # @contents = [Name, Mime::MediaType, Mime::SubType]
218
+ case @contents[1]
219
+ when 'image'
220
+ %[<a href="#{@contents[0]}"><img src="#{@contents[0]}" alt="#{@contents[0]}" class="img-rounded img-responsive" /></a>]
221
+ when 'video'
222
+ %[<video src="#{@contents[0]}" controls></video>]
223
+ when 'audio'
224
+ %[<audio src="#{@contents[0]}" controls></audio>]
225
+ else
226
+ %[<a href="#{@contents[0]}">#{@contents[0].split("/").last}</a>]
227
+ end
211
228
  end
212
229
  end
213
230
  end
@@ -17,5 +17,5 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_development_dependency "bundler", "~> 1.3"
19
19
  spec.add_development_dependency "rake"
20
- spec.add_dependency('raf-parser', '>=0.2.2')
20
+ spec.add_dependency('raf-parser', '>=0.2.3')
21
21
  end
@@ -7,13 +7,29 @@
7
7
  # $ vi ~/.raf2html.yaml
8
8
  #
9
9
  # == 設定項目
10
- # コンバート時にHTMLファイルに埋め込むスタイルシート(デフォルト:nil)
11
- # css: "~/raf2html.css"
10
+ # コンバート時にHTMLファイルに埋め込むスタイルシート(デフォルト:"")
11
+ #css: "~/raf2html.css"
12
+
13
+ # コンバート時にHTMLファイルに埋め込むjavascript(デフォルト:"")
14
+ #js: "~/raf2html.js"
15
+
16
+ # リファレンス記法の「.%」を変換する拡張子(デフォルト:.html)
17
+ #extension: ".html"
18
+
19
+ # 画像やビデオ、音声などを配置するディレクトリ(デフォルト:"")
20
+ #media_directory: "/usr/local/media"
21
+
22
+ # HTMLタグをカスタマイズするためのRubyファイル(デフォルト:"")
23
+ #custom_element: "/home/myname/raf2html/mycustom.rb"
24
+
12
25
  # ドキュメントのフォーマット(デフォルト:ja)
13
- language: "ja"
26
+ #language: "ja"
27
+
14
28
  # 目次(index)を作成するかどうか(デフォルト: true)
15
- index: true
29
+ #index: true
30
+
16
31
  # メタデータを作成するかどうか(デフォルト: true)
17
- metadata: true
32
+ #metadata: true
33
+
18
34
  # HTMLヘッダを出力"しない"かどうか(デフォルト: false)
19
- quiet: false
35
+ #quiet: false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raf2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - garin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-04 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.2
47
+ version: 0.2.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.2
54
+ version: 0.2.3
55
55
  description: raf is simple document format
56
56
  email:
57
57
  - garin54@gmail.com