bluefeather 0.10 → 0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/author-and-license.html +24 -0
- data/doc/basic-usage.bfdoc +25 -1
- data/doc/basic-usage.html +296 -0
- data/doc/class-reference.html +165 -0
- data/doc/difference.html +69 -0
- data/doc/en/author-and-license.html +29 -0
- data/doc/en/basic-usage.bfdoc +56 -31
- data/doc/en/basic-usage.html +303 -0
- data/doc/en/class-reference.html +15 -0
- data/doc/en/difference.html +72 -0
- data/doc/en/format-extension.html +424 -0
- data/doc/en/index.bfdoc +1 -1
- data/doc/en/index.html +48 -0
- data/doc/en/metadata-reference.html +15 -0
- data/doc/format-extension.html +426 -0
- data/doc/index.bfdoc +1 -1
- data/doc/index.html +46 -0
- data/doc/metadata-reference.html +108 -0
- data/lib/bluefeather.rb +8 -5
- data/lib/bluefeather/cui.rb +43 -31
- data/spec/cui.rb +73 -0
- data/spec/lib/common.rb +85 -0
- metadata +17 -2
data/doc/difference.html
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>BlueClothとの主な違い - BlueFeather マニュアル</title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
6
|
+
<link rel="stylesheet" type="text/css" href="black.css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<div class="back"><a href="index.html">BlueFeather マニュアル</a></div>
|
11
|
+
|
12
|
+
<h1 id="bfheader-5872a94268680416a4c9ad637cb87099">BlueClothとの主な違い</h1>
|
13
|
+
|
14
|
+
<ul>
|
15
|
+
<li><a href="#bfheader-1b0d3cd7253b68158eb5298a2fd35575" rel="toc">記法の拡張</a></li>
|
16
|
+
<li><a href="#bfheader-c3b3392cb271f29d0b8632f5352ee4d0" rel="toc">インターフェースの変更</a></li>
|
17
|
+
<li><a href="#bfheader-7b1d5b9d0a5d5213978f58fba2f7c25e" rel="toc">完全なHTML文書の生成</a></li>
|
18
|
+
<li><a href="#bfheader-0c430062063e949250ad8ecf44a97606" rel="toc">BlueCloth 1.0.0 における既知のバグの修正</a></li>
|
19
|
+
<li><a href="#bfheader-267dd468927552bd5d2a6d4c15c5ca04" rel="toc">空要素タグの閉じ方を変更</a></li>
|
20
|
+
</ul>
|
21
|
+
|
22
|
+
<h2 id="bfheader-1b0d3cd7253b68158eb5298a2fd35575">記法の拡張</h2>
|
23
|
+
|
24
|
+
<p><a href="http://michelf.com/projects/php-markdown/extra/">PHP Markdown Extra</a>から多くの拡張(定義リスト、表組み、など)を取り込み、さらに目次生成や強制ブロック区切りなどの独自拡張を実装しています。
|
25
|
+
詳しくは<a href="format-extension.html">Markdown記法の拡張</a>を参照してください。</p>
|
26
|
+
|
27
|
+
<h2 id="bfheader-c3b3392cb271f29d0b8632f5352ee4d0">インターフェースの変更</h2>
|
28
|
+
|
29
|
+
<p>BlueCloth では、文字列を継承した BlueCloth クラスのオブジェクトを生成し、そのオブジェクトに対して to_html を呼ぶことで変換を行います。</p>
|
30
|
+
|
31
|
+
<pre><code>require 'bluecloth'
|
32
|
+
|
33
|
+
puts BlueCloth.new(str).to_html
|
34
|
+
</code></pre>
|
35
|
+
|
36
|
+
<p>対して BlueFeather では、 BlueFeather モジュールのメソッドを直接呼んで変換を行うのが、もっとも一般的な方法です。</p>
|
37
|
+
|
38
|
+
<pre><code>require 'bluefeather'
|
39
|
+
|
40
|
+
puts BlueFeather.parse(str)
|
41
|
+
</code></pre>
|
42
|
+
|
43
|
+
<p>また、<code>parse_file</code> や <code>parse_document</code> など、いくつかのメソッドが新設されています。
|
44
|
+
詳しくは<a href="basic-usage.html">基本的な使い方</a>を参照してください。</p>
|
45
|
+
|
46
|
+
<h2 id="bfheader-7b1d5b9d0a5d5213978f58fba2f7c25e">完全なHTML文書の生成</h2>
|
47
|
+
|
48
|
+
<p><a href="http://maruku.rubyforge.org/">Maruku</a> から取り込んだ機能として、部分的なhtml片だけではなく、DTD宣言やhead要素まで含んだ完全なhtml文書を生成できる機能があります。
|
49
|
+
また、メタデータを記述することにより、出力されるhtml文書のタイトルや、CSSファイルのURLも指定することが可能です。</p>
|
50
|
+
|
51
|
+
<p>詳しくは<a href="basic-usage.html">基本的な使い方</a>、及び<a href="metadata-reference.html">メタデータリファレンス</a>を参照してください。</p>
|
52
|
+
|
53
|
+
<h2 id="bfheader-0c430062063e949250ad8ecf44a97606">BlueCloth 1.0.0 における既知のバグの修正</h2>
|
54
|
+
|
55
|
+
<p>以下のバグの修正を行いました。</p>
|
56
|
+
|
57
|
+
<ol>
|
58
|
+
<li>一部の正規表現に、文字コード Shift-JIS が指定されている(= Shift-JIS 以外のマルチバイト文字列を正しく扱えない)</li>
|
59
|
+
<li>一部の文字が含まれていると、<code><mailaddress@example.com></code> 形式の記述が mailto: リンクとして変換されない(GMailのエイリアス文字 <code>+</code> など)</li>
|
60
|
+
<li>リンクID定義を、4つ以上のスペースやタブでインデントしてもコードブロックにできない</li>
|
61
|
+
<li>水平線(<code><hr /></code>)タグを、4つ以上のスペースやタブでインデントしてもコードブロックにできない</li>
|
62
|
+
</ol>
|
63
|
+
|
64
|
+
<h2 id="bfheader-267dd468927552bd5d2a6d4c15c5ca04">空要素タグの閉じ方を変更</h2>
|
65
|
+
|
66
|
+
<p>BlueCloth で <code><tag/></code> となっていた空要素タグの終端を、<code><tag /></code> に変更しました。</p>
|
67
|
+
|
68
|
+
</body>
|
69
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Author and License - BlueFeather Manual</title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
6
|
+
<link rel="stylesheet" type="text/css" href="black.css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<div class="back"><a href="index.html">BlueFeather Manual</a></div>
|
11
|
+
|
12
|
+
<h1 id="bfheader-e34a2a350728e95ad54ff76bbdcacac6">Author and License</h1>
|
13
|
+
|
14
|
+
<p>BlueFeather is a free software. it is distributed by General Public License
|
15
|
+
(GPL) version 2. For details, see top of <code>bluefeather.rb</code>, and <code>license/</code> directory.</p>
|
16
|
+
|
17
|
+
<ul>
|
18
|
+
<li><a href="http://en.wikipedia.org/wiki/GNU_General_Public_License">Wikipedia - GNU General Public License</a></li>
|
19
|
+
</ul>
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
<p>If you want to send requests, comments, or bug reports to BlueFeather, please
|
24
|
+
feel free to post messages from
|
25
|
+
<a href="http://ruby.morphball.net/bluefeather/index_en.html">http://ruby.morphball.net/bluefeather/index_en.html</a> or to send mail to Dice.
|
26
|
+
(<a href="mailto:tetradice@gmail.com">tetradice@gmail.com</a>)</p>
|
27
|
+
|
28
|
+
</body>
|
29
|
+
</html>
|
data/doc/en/basic-usage.bfdoc
CHANGED
@@ -43,7 +43,26 @@ command convert Markdown text to html.
|
|
43
43
|
example3.bftext => example3.html (10499 byte)
|
44
44
|
%
|
45
45
|
|
46
|
-
|
46
|
+
|
47
|
+
### Option for Forcing to Convert (`--force`)
|
48
|
+
|
49
|
+
In default, `bluefeather` command converts only input files that were modified.
|
50
|
+
|
51
|
+
% bluefeather example1.bftext
|
52
|
+
example1.bftext => example1.html (4240 byte)
|
53
|
+
% bluefeather example1.bftext
|
54
|
+
%
|
55
|
+
|
56
|
+
If you want to convert all files despite modified time of them, use `--force` option.
|
57
|
+
|
58
|
+
% bluefeather example1.bftext
|
59
|
+
example1.bftext => example1.html (4240 byte)
|
60
|
+
% bluefeather --force example1.bftext
|
61
|
+
example1.bftext => example1.html (4240 byte)
|
62
|
+
%
|
63
|
+
|
64
|
+
If you know better about other options, see the section of [Command-line Option](#commandline-options).
|
65
|
+
|
47
66
|
|
48
67
|
### Extname Switch
|
49
68
|
|
@@ -153,36 +172,42 @@ test3.html
|
|
153
172
|
|
154
173
|
### Command-line Options {#commandline-options}
|
155
174
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
175
|
+
|
176
|
+
~~~~
|
177
|
+
% bluefeather --help
|
178
|
+
bluefeather - Extended Markdown Converter
|
179
|
+
|
180
|
+
Usage: bluefeather [options] file1 [file2 file3 ..]
|
181
|
+
|
182
|
+
Options:
|
183
|
+
-e, --encoding NAME parse input files as encoding of NAME.
|
184
|
+
(s[hift-jis] / e[uc-jp] / u[tf-8] / a[scii]
|
185
|
+
default: 'utf-8')
|
186
|
+
-f, --format TYPE specify format.
|
187
|
+
(t[ext] => text mode
|
188
|
+
d[ocument] => document mode)
|
189
|
+
--force write even if target files have not changed.
|
190
|
+
(default: only if target files have changed)
|
191
|
+
-h, --help show this help.
|
192
|
+
-o, --output DIR output files to DIR. (default: same as input file)
|
193
|
+
-q, --quiet no output to stderr.
|
194
|
+
--suffix .SUF specify suffix of output files. (default: '.html')
|
195
|
+
-v, --verbose verbose mode - output detail of operation.
|
196
|
+
--version show BlueFeather version.
|
197
|
+
|
198
|
+
Advanced Usage:
|
199
|
+
* If specify files only '-', bluefeather read from stdin and write to stdout.
|
200
|
+
|
201
|
+
|
202
|
+
Example:
|
203
|
+
bluefeather *.bftext *.bfdoc
|
204
|
+
bluefeather -v --sufix .xhtml -o ../ sample.markdown
|
205
|
+
bluefeather -
|
206
|
+
|
207
|
+
More info:
|
208
|
+
see <http://ruby.morphball.net/bluefeather/>
|
209
|
+
%
|
210
|
+
~~~~
|
186
211
|
|
187
212
|
Use in Ruby Script
|
188
213
|
----
|
@@ -0,0 +1,303 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Installing and Basic Usage - BlueFeather Manual</title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
6
|
+
<link rel="stylesheet" type="text/css" href="black.css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<div class="back"><a href="index.html">BlueFeather Manual</a></div>
|
11
|
+
|
12
|
+
<h1 id="bfheader-1a89f3bf198317c0b4f86253e0bdecd3">Installing and Basic Usage</h1>
|
13
|
+
|
14
|
+
<p>This document describes only usage of the software. If you want to know about
|
15
|
+
syntax, see <a href="format-extension.html">Markdown Syntax Extension</a>.</p>
|
16
|
+
|
17
|
+
<ul>
|
18
|
+
<li><a href="#bfheader-349838fb1d851d3e2014b9fe39203275" rel="toc">Install</a></li>
|
19
|
+
<li><a href="#bfheader-5a1a4bf445864249197159704f61a362" rel="toc">Use by Command-line</a>
|
20
|
+
<ul>
|
21
|
+
<li><a href="#bfheader-972e73b7a882d0802a4e3a16946a2f94" rel="toc">Basic</a></li>
|
22
|
+
<li><a href="#bfheader-f8a5ceba4ab3ef0272c92fbcece80dd8" rel="toc">Option for Forcing to Convert (<code>--force</code>)</a></li>
|
23
|
+
<li><a href="#bfheader-3af22b762da471e997070a49f8982292" rel="toc">Extname Switch</a></li>
|
24
|
+
<li><a href="#bfheader-e009128587b41717d006d612146b32a8" rel="toc">Document Metadata</a></li>
|
25
|
+
<li><a href="#bfheader-525ec2a4890848edb94043d7c1bcfd12" rel="toc">stdin-mode</a></li>
|
26
|
+
<li><a href="#commandline-options" rel="toc">Command-line Options</a></li>
|
27
|
+
</ul></li>
|
28
|
+
<li><a href="#bfheader-ea4b8233c187e9e87b21ba52d38720e8" rel="toc">Use in Ruby Script</a>
|
29
|
+
<ul>
|
30
|
+
<li><a href="#bfheader-972e73b7a882d0802a4e3a16946a2f94" rel="toc">Basic</a></li>
|
31
|
+
<li><a href="#bfheader-6567398110bdf1f81916b86d04f3e1e3" rel="toc">Generate HTML Document</a></li>
|
32
|
+
<li><a href="#bfheader-c2d7181a11dd80ca24bcfab69176f3c2" rel="toc">Get document metadata</a></li>
|
33
|
+
</ul></li>
|
34
|
+
</ul>
|
35
|
+
|
36
|
+
<h2 id="bfheader-349838fb1d851d3e2014b9fe39203275">Install</h2>
|
37
|
+
|
38
|
+
<p>Run setup.rb. Then required files will be copied and installing will be complete.</p>
|
39
|
+
|
40
|
+
<pre><code>% ruby setup.rb
|
41
|
+
</code></pre>
|
42
|
+
|
43
|
+
<p>Or use RubyGems.</p>
|
44
|
+
|
45
|
+
<pre><code>% gem install bluefeather
|
46
|
+
</code></pre>
|
47
|
+
|
48
|
+
<h2 id="bfheader-5a1a4bf445864249197159704f61a362">Use by Command-line</h2>
|
49
|
+
|
50
|
+
<h3 id="bfheader-972e73b7a882d0802a4e3a16946a2f94">Basic</h3>
|
51
|
+
|
52
|
+
<p>If installing is correctly completed, you can use <code>bluefeather</code> command. This
|
53
|
+
command convert Markdown text to html.</p>
|
54
|
+
|
55
|
+
<pre><code>bluefeather [options] file1 [file2] [file3] ...
|
56
|
+
</code></pre>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<pre><code>% bluefeather *.bftext
|
61
|
+
example1.bftext => example1.html (4240 byte)
|
62
|
+
example2.bftext => example2.html (5613 byte)
|
63
|
+
example3.bftext => example3.html (10499 byte)
|
64
|
+
%
|
65
|
+
</code></pre>
|
66
|
+
|
67
|
+
<h3 id="bfheader-f8a5ceba4ab3ef0272c92fbcece80dd8">Option for Forcing to Convert (<code>--force</code>)</h3>
|
68
|
+
|
69
|
+
<p>In default, <code>bluefeather</code> command converts only input files that were modified.</p>
|
70
|
+
|
71
|
+
<pre><code>% bluefeather example1.bftext
|
72
|
+
example1.bftext => example1.html (4240 byte)
|
73
|
+
% bluefeather example1.bftext
|
74
|
+
%
|
75
|
+
</code></pre>
|
76
|
+
|
77
|
+
<p>If you want to convert all files despite modified time of them, use <code>--force</code> option.</p>
|
78
|
+
|
79
|
+
<pre><code>% bluefeather example1.bftext
|
80
|
+
example1.bftext => example1.html (4240 byte)
|
81
|
+
% bluefeather --force example1.bftext
|
82
|
+
example1.bftext => example1.html (4240 byte)
|
83
|
+
%
|
84
|
+
</code></pre>
|
85
|
+
|
86
|
+
<p>If you know better about other options, see the section of <a href="#commandline-options">Command-line Option</a>.</p>
|
87
|
+
|
88
|
+
<h3 id="bfheader-3af22b762da471e997070a49f8982292">Extname Switch</h3>
|
89
|
+
|
90
|
+
<p><code>bluefeather</code> command switches by extname of an input file how generate a html file.</p>
|
91
|
+
|
92
|
+
<dl>
|
93
|
+
<dt><code>.md</code>, <code>.bfdoc</code></dt>
|
94
|
+
<dd>generate html document</dd>
|
95
|
+
<dt>others</dt>
|
96
|
+
<dd>generate html part</dd>
|
97
|
+
</dl>
|
98
|
+
|
99
|
+
<p>For example, see the text.</p>
|
100
|
+
|
101
|
+
<pre><code>test paragraph.
|
102
|
+
</code></pre>
|
103
|
+
|
104
|
+
<p>If this text is named '<code>test1.bftext</code>', <code>bluefeather</code> generates <code>test1.html</code> such as this.</p>
|
105
|
+
|
106
|
+
<pre><code><p>test paragraph.</p>
|
107
|
+
</code></pre>
|
108
|
+
|
109
|
+
<p>But this text is named '<code>test1.bfdoc</code>', generated html is changed.</p>
|
110
|
+
|
111
|
+
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
112
|
+
<html>
|
113
|
+
<head>
|
114
|
+
<title>no title (Generated by BlueFeather)</title>
|
115
|
+
</head>
|
116
|
+
<body>
|
117
|
+
|
118
|
+
<p>test paragraph.</p>
|
119
|
+
|
120
|
+
</body>
|
121
|
+
</html>
|
122
|
+
</code></pre>
|
123
|
+
|
124
|
+
<p>If the converted document is include h1 element, BlueFeather use it's content for title of html document. </p>
|
125
|
+
|
126
|
+
<dl>
|
127
|
+
<dt>test2.bfdoc</dt>
|
128
|
+
<dd><pre><code>Test Document
|
129
|
+
=============
|
130
|
+
|
131
|
+
test paragraph.
|
132
|
+
</code></pre></dd>
|
133
|
+
<dt>test2.html (output)</dt>
|
134
|
+
<dd><pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
135
|
+
<html>
|
136
|
+
<head>
|
137
|
+
<title>Test Document</title>
|
138
|
+
</head>
|
139
|
+
<body>
|
140
|
+
|
141
|
+
<h1 id="bfheader-a5decd745d43af4aa8cf62eef5be43ac">Test Document</h1>
|
142
|
+
|
143
|
+
<p>test paragraph.</p>
|
144
|
+
|
145
|
+
</body>
|
146
|
+
</html>
|
147
|
+
</code></pre></dd>
|
148
|
+
</dl>
|
149
|
+
|
150
|
+
<h3 id="bfheader-e009128587b41717d006d612146b32a8">Document Metadata</h3>
|
151
|
+
|
152
|
+
<p>You can add <em>document metadata</em> to files which have extname <code>.bfdoc</code> or <code>.md</code></p>
|
153
|
+
|
154
|
+
<dl>
|
155
|
+
<dt>test3.bfdoc</dt>
|
156
|
+
<dd><pre><code>Title: Test Document
|
157
|
+
CSS: style.css
|
158
|
+
|
159
|
+
Test paragraph.
|
160
|
+
</code></pre></dd>
|
161
|
+
<dt>test3.html</dt>
|
162
|
+
<dd><pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
163
|
+
<html>
|
164
|
+
<head>
|
165
|
+
<title>Test Document</title>
|
166
|
+
<link rel="stylesheet" type="text/css" href="style.css" />
|
167
|
+
</head>
|
168
|
+
<body>
|
169
|
+
|
170
|
+
<p>Test paragraph.</p>
|
171
|
+
|
172
|
+
</body>
|
173
|
+
</html>
|
174
|
+
</code></pre></dd>
|
175
|
+
</dl>
|
176
|
+
|
177
|
+
<p>If you know better about metadata, see the section of <a href="metadata-reference.html">Metadata Reference</a>.</p>
|
178
|
+
|
179
|
+
<h3 id="bfheader-525ec2a4890848edb94043d7c1bcfd12">stdin-mode</h3>
|
180
|
+
|
181
|
+
<p>If you use stdin and stdout, specify a parameter only <code>-</code>. This mode is useful for pipe-line.</p>
|
182
|
+
|
183
|
+
<pre><code>% bluefeather -
|
184
|
+
</code></pre>
|
185
|
+
|
186
|
+
<h3 id="commandline-options">Command-line Options</h3>
|
187
|
+
|
188
|
+
<pre><code>% bluefeather --help
|
189
|
+
bluefeather - Extended Markdown Converter
|
190
|
+
|
191
|
+
Usage: bluefeather [options] file1 [file2 file3 ..]
|
192
|
+
|
193
|
+
Options:
|
194
|
+
-e, --encoding NAME parse input files as encoding of NAME.
|
195
|
+
(s[hift-jis] / e[uc-jp] / u[tf-8] / a[scii]
|
196
|
+
default: 'utf-8')
|
197
|
+
-f, --format TYPE specify format.
|
198
|
+
(t[ext] => text mode
|
199
|
+
d[ocument] => document mode)
|
200
|
+
--force write even if target files have not changed.
|
201
|
+
(default: only if target files have changed)
|
202
|
+
-h, --help show this help.
|
203
|
+
-o, --output DIR output files to DIR. (default: same as input file)
|
204
|
+
-q, --quiet no output to stderr.
|
205
|
+
--suffix .SUF specify suffix of output files. (default: '.html')
|
206
|
+
-v, --verbose verbose mode - output detail of operation.
|
207
|
+
--version show BlueFeather version.
|
208
|
+
|
209
|
+
Advanced Usage:
|
210
|
+
* If specify files only '-', bluefeather read from stdin and write to stdout.
|
211
|
+
|
212
|
+
|
213
|
+
Example:
|
214
|
+
bluefeather *.bftext *.bfdoc
|
215
|
+
bluefeather -v --sufix .xhtml -o ../ sample.markdown
|
216
|
+
bluefeather -
|
217
|
+
|
218
|
+
More info:
|
219
|
+
see <http://ruby.morphball.net/bluefeather/>
|
220
|
+
%
|
221
|
+
</code></pre>
|
222
|
+
|
223
|
+
<h2 id="bfheader-ea4b8233c187e9e87b21ba52d38720e8">Use in Ruby Script</h2>
|
224
|
+
|
225
|
+
<h3 id="bfheader-972e73b7a882d0802a4e3a16946a2f94">Basic</h3>
|
226
|
+
|
227
|
+
<p>Most basic method is <code>BlueFeather.parse</code>.</p>
|
228
|
+
|
229
|
+
<pre><code>require 'bluefeather'
|
230
|
+
|
231
|
+
str = "most basic example."
|
232
|
+
puts BlueFeather.parse(str) #=> "<p>most basic example.</p>"
|
233
|
+
</code></pre>
|
234
|
+
|
235
|
+
<p>And you can use <code>BlueFeather.parse_file</code>.</p>
|
236
|
+
|
237
|
+
<pre><code>BlueFeather.parse_file('test1.txt')
|
238
|
+
BlueFeather.parse_file('test2.markdown')
|
239
|
+
BlueFeather.parse_file('test3.bftext')
|
240
|
+
</code></pre>
|
241
|
+
|
242
|
+
<h3 id="bfheader-6567398110bdf1f81916b86d04f3e1e3">Generate HTML Document</h3>
|
243
|
+
|
244
|
+
<p>If you want a html document not html fragment, you may use <code>parse_document</code> or <code>parse_document_file</code>.</p>
|
245
|
+
|
246
|
+
<dl>
|
247
|
+
<dt>test.bfdoc</dt>
|
248
|
+
<dd><pre><code>The sentence is expected as HTML.
|
249
|
+
</code></pre></dd>
|
250
|
+
<dt>test.rb</dt>
|
251
|
+
<dd><pre><code>require 'bluefeather'
|
252
|
+
|
253
|
+
puts '-- parse_file --'
|
254
|
+
puts BlueFeather.parse_file('test.bfdoc')
|
255
|
+
|
256
|
+
puts '-- parse_document_file --'
|
257
|
+
puts BlueFeather.parse_document_file('test.bfdoc')
|
258
|
+
</code></pre></dd>
|
259
|
+
<dt>Result</dt>
|
260
|
+
<dd><pre><code>-- parse_file --
|
261
|
+
<p>The sentence is expected as HTML.</p>
|
262
|
+
|
263
|
+
-- parse_document_file --
|
264
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
265
|
+
<html>
|
266
|
+
<head>
|
267
|
+
<title>no title (Generated by BlueFeather)</title>
|
268
|
+
</head>
|
269
|
+
<body>
|
270
|
+
|
271
|
+
<p>The sentence is expected as HTML.</p>
|
272
|
+
|
273
|
+
</body>
|
274
|
+
</html>
|
275
|
+
</code></pre></dd>
|
276
|
+
</dl>
|
277
|
+
|
278
|
+
<h3 id="bfheader-c2d7181a11dd80ca24bcfab69176f3c2">Get document metadata</h3>
|
279
|
+
|
280
|
+
<p>If you want to get directly metadata of document, instead of BlueFeather module method, you should use <code>BlueFeather::Document</code> class.</p>
|
281
|
+
|
282
|
+
<pre><code>doc = BlueFeather::Document.parse(<<EOS)
|
283
|
+
Title: test document
|
284
|
+
CSS: style.css
|
285
|
+
|
286
|
+
test paragraph.
|
287
|
+
EOS
|
288
|
+
|
289
|
+
p doc['title'] # => "test document"
|
290
|
+
p doc['css'] # => "style.css"
|
291
|
+
p doc[:css] # => "style.css"
|
292
|
+
p doc['undefined'] # => nil
|
293
|
+
|
294
|
+
p doc.body # => "test paragraph."
|
295
|
+
</code></pre>
|
296
|
+
|
297
|
+
<p><code>to_html</code> parses the text and generates an html document actually.</p>
|
298
|
+
|
299
|
+
<pre><code>doc.to_html
|
300
|
+
</code></pre>
|
301
|
+
|
302
|
+
</body>
|
303
|
+
</html>
|