ulmul 0.1.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.
- data/ChangeLog +4 -0
- data/README-en.xhtml +294 -0
- data/README-ja +162 -0
- data/README-ja.xhtml +307 -0
- data/Rakefile +75 -0
- data/bin/ulmul.rb +561 -0
- data/favicon.ico +0 -0
- data/index.html +28 -0
- data/lib/ulmul.rb +561 -0
- data/ruby.jpg +0 -0
- data/setup.rb +1585 -0
- data/slidy.js +2778 -0
- data/style.css +65 -0
- data/tests/ulmul_test.rb +14 -0
- data/ulmul-slidy.css +112 -0
- data/ulmul.gemspec +33 -0
- metadata +76 -0
data/README-ja.xhtml
ADDED
@@ -0,0 +1,307 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
|
3
|
+
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
8
|
+
<title>ULMUL (ulmul.rb) 取扱説明書</title>
|
9
|
+
<meta name="author" content="takeshi" />
|
10
|
+
<meta name="copyright" content="Copyright © 2009 takeshi" />
|
11
|
+
<link rel="stylesheet" href="style.css" type="text/css" />
|
12
|
+
<link rel="shortcut icon" href="favicon.ico" />
|
13
|
+
</head>
|
14
|
+
<body>
|
15
|
+
<div class="slide cover">
|
16
|
+
<h1 id="LABEL-1">ULMUL (ulmul.rb) 取扱説明書</h1>
|
17
|
+
<p>
|
18
|
+
ULMUL (ulmul.rb) は独自の軽量マークアップ言語 (Ultra Lightweight MarkUp Language) を
|
19
|
+
(X)HTMLファイルへ変換します。文章中のTeXスタイルで書かれた数式をMathMLに変換できるのが特徴です。
|
20
|
+
また、ウェブ・ブラウザ+CSS+XHTML+JavaScriptを使ったプレゼン環境
|
21
|
+
HTML Slidy <a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> に対応したhtmlかxhtmlも出力可能です。
|
22
|
+
sourceforge.jpのWikiシンタックス <a href="http://sourceforge.jp/projects/sourceforge/wiki/Guide%2FWikiSyntax">http://sourceforge.jp/projects/sourceforge/wiki/Guide%2FWikiSyntax</a>
|
23
|
+
と同様なことができるようになることをめざして開発しています。
|
24
|
+
</p>
|
25
|
+
<p>
|
26
|
+
<a href="http://ulmul.rubyforge.org/">http://ulmul.rubyforge.org/</a> がホームページです。
|
27
|
+
<a href="http://rubyforge.org/projects/ulmul/">http://rubyforge.org/projects/ulmul/</a> から関連するファイルをダウンロードすることができます。
|
28
|
+
</p>
|
29
|
+
<p>
|
30
|
+
作者は作者のwebページと学会発表用のスライドを作るのにULMULを使っています。
|
31
|
+
<a href="http://loto.sourceforge.net/feram/">http://loto.sourceforge.net/feram/</a> のソースは
|
32
|
+
<a href="http://loto.sourceforge.net/feram/README">http://loto.sourceforge.net/feram/README</a> です。
|
33
|
+
<a href="http://loto.sourceforge.net/feram/doc/film.xhtml">http://loto.sourceforge.net/feram/doc/film.xhtml</a> というスライドは
|
34
|
+
<a href="http://loto.sourceforge.net/feram/doc/film.txt">http://loto.sourceforge.net/feram/doc/film.txt</a> から生成されました。
|
35
|
+
</p>
|
36
|
+
<br />Contents:
|
37
|
+
<ul>
|
38
|
+
<li><a href="#LABEL-2">特徴</a></li>
|
39
|
+
<li><a href="#LABEL-3">インストール方法</a>
|
40
|
+
<ul>
|
41
|
+
<li><a href="#LABEL-4">I. setup.rbを使う方法</a></li>
|
42
|
+
<li><a href="#LABEL-5">II. RubyGemsを使えば簡単にインストールができます</a></li>
|
43
|
+
</ul></li>
|
44
|
+
<li><a href="#LABEL-6">必要なファイル</a></li>
|
45
|
+
<li><a href="#LABEL-7">ULMULテキストの書き方</a>
|
46
|
+
<ul>
|
47
|
+
<li><a href="#LABEL-8">各行の種類</a></li>
|
48
|
+
<li><a href="#LABEL-16">その他のルール</a></li>
|
49
|
+
<li><a href="#LABEL-17">数式の書き方</a></li>
|
50
|
+
<li><a href="#LABEL-18">図の挿入方法</a></li>
|
51
|
+
</ul></li>
|
52
|
+
<li><a href="#LABEL-19">使用方法</a>
|
53
|
+
<ul>
|
54
|
+
<li><a href="#LABEL-20">例</a></li>
|
55
|
+
<li><a href="#LABEL-21">コマンド・ライン・オプション</a></li>
|
56
|
+
</ul></li>
|
57
|
+
<li><a href="#LABEL-28">ulmul.rbの仕組み</a></li>
|
58
|
+
<li><a href="#LABEL-29">著作権表示</a></li>
|
59
|
+
<li><a href="#LABEL-30">作者</a></li>
|
60
|
+
</ul>
|
61
|
+
|
62
|
+
</div>
|
63
|
+
|
64
|
+
|
65
|
+
<div class="slide">
|
66
|
+
<h2 id="LABEL-2">特徴</h2>
|
67
|
+
|
68
|
+
<ul>
|
69
|
+
<li>文章中の2つのドル記号($)で挟まれた部分とEq.…/Eq.で挟まれた行が数式としてTeX形式からMathML形式に変換されます。
|
70
|
+
MathMLとはXMLで数式を記述するための規格です。込み入った規格なので人間が直接MathMLを記述する
|
71
|
+
ことは想定されていませんが、ULMULでやっているようにTeXなどからの変換により生成することができます。
|
72
|
+
Firefoxのバージョン3.0以上で読めるようです。
|
73
|
+
math_ml.rb <a href="http://www.hinet.mydns.jp/?mathml.rb">http://www.hinet.mydns.jp/?mathml.rb</a> を使っています。</li>
|
74
|
+
<li>ウェブ・ブラウザ+CSS+XHTML+JavaScriptを使ったプレゼン環境
|
75
|
+
Slidy <a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> に対応したhtmlかxhtmlも出力可能です。
|
76
|
+
ただし、PowerPointより優れたプレゼンができるかというと、そうとも限りません。</li>
|
77
|
+
<li>=begin, =end はあってもなくてもかまいません。</li>
|
78
|
+
<li>行を#ではじめるとコメントになります。</li>
|
79
|
+
<li>ライブラリとしても使えます。</li>
|
80
|
+
<li>subs_rulesに俺ルールを加えることができます。</li>
|
81
|
+
<li>目次 (Contents) を自動的に生成できます。</li>
|
82
|
+
<li>はじめの「= ABCD EFGH」がタイトルになります。Slidyの表紙にもなります。</li>
|
83
|
+
<li>テキストファイルはutf-8で書きます。自然言語は--language=jaなどとオプションで指定できます。</li>
|
84
|
+
</ul>
|
85
|
+
<p>
|
86
|
+
などが特徴です。
|
87
|
+
</p>
|
88
|
+
</div>
|
89
|
+
|
90
|
+
|
91
|
+
<div class="slide">
|
92
|
+
<h2 id="LABEL-3">インストール方法</h2>
|
93
|
+
<p>
|
94
|
+
2通りのインストール方法があります。
|
95
|
+
</p>
|
96
|
+
<h3 id="LABEL-4">I. setup.rbを使う方法</h3>
|
97
|
+
<p>
|
98
|
+
パッケージ ulmul-X.Y.Z.tgz を次のようにインストールします:
|
99
|
+
</p>
|
100
|
+
<pre> $ tar zxf ulmul-X.Y.Z.tgz
|
101
|
+
$ cd ulmul-X.Y.Z
|
102
|
+
$ su
|
103
|
+
# ruby setup.rb
|
104
|
+
</pre>
|
105
|
+
<p>
|
106
|
+
なお、ULMULを使うにはeimxmlライブラリとmathmlライブラリとが必要です。
|
107
|
+
</p>
|
108
|
+
<h3 id="LABEL-5">II. RubyGemsを使えば簡単にインストールができます</h3>
|
109
|
+
<p>
|
110
|
+
gemでインストールすればeimxmlライブラリとmathmlライブラリとは自動的にインストールされます:
|
111
|
+
</p>
|
112
|
+
<pre> $ su
|
113
|
+
# gem install ulmul
|
114
|
+
</pre>
|
115
|
+
</div>
|
116
|
+
|
117
|
+
|
118
|
+
<div class="slide">
|
119
|
+
<h2 id="LABEL-6">必要なファイル</h2>
|
120
|
+
|
121
|
+
<ul>
|
122
|
+
<li>ulmul.rb Rubyスクリプト。</li>
|
123
|
+
<li>slidy.js Slidy用JavaScript。オリジナルをちょっとだけ改変。</li>
|
124
|
+
<li>ulmul-slidy.css Slidy用CSSファイル。オリジナルを大幅に改変。</li>
|
125
|
+
<li>style.css 普通のウェブページ用CSSファイル。</li>
|
126
|
+
</ul>
|
127
|
+
<p>
|
128
|
+
もしあなたがULMULをgemでインストールしたなら、上記のファイル
|
129
|
+
は /usr/local/lib/ruby/gems/1.8/gems/ulmul-X.Y.Z/
|
130
|
+
もしくは /usr/lib/ruby/gems/1.8/gems/ulmul-X.Y.Z/
|
131
|
+
以下にあるかもしれません。
|
132
|
+
</p>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
|
136
|
+
<div class="slide">
|
137
|
+
<h2 id="LABEL-7">ULMULテキストの書き方</h2>
|
138
|
+
<p>
|
139
|
+
ULMULテキストのエンコーディングにはutf-8を使ってください。
|
140
|
+
</p>
|
141
|
+
<h3 id="LABEL-8">各行の種類</h3>
|
142
|
+
<h4 id="LABEL-9">空行 (empty)</h4>
|
143
|
+
<p>
|
144
|
+
空行は段落を分割します。
|
145
|
+
</p>
|
146
|
+
<h4 id="LABEL-10">ヘディング (heading)</h4>
|
147
|
+
<p>
|
148
|
+
"= ", "== ", "=== ", "==== ", "===== ", または "====== " で始めてください。
|
149
|
+
「= ABCD EFGH」ならABCD EFGHがタイトルになります。Slidyの表紙にもなります。
|
150
|
+
</p>
|
151
|
+
<h4 id="LABEL-11">アスタリスクで始まる行は箇条書きになります (asterisk)</h4>
|
152
|
+
<p>
|
153
|
+
6段までネストした箇条書きが可能です:
|
154
|
+
</p>
|
155
|
+
<pre>" *"
|
156
|
+
" *"
|
157
|
+
" *"
|
158
|
+
" *"
|
159
|
+
" *"
|
160
|
+
</pre>
|
161
|
+
<h4 id="LABEL-12">オフセットされて書かれた行はそのまま出力 (verbatim, pre) されます (offset)</h4>
|
162
|
+
<p>
|
163
|
+
1つスペースを置いて書き始めた行はverbatimになります。
|
164
|
+
</p>
|
165
|
+
<h4 id="LABEL-13">終わり (end)</h4>
|
166
|
+
<p>
|
167
|
+
EOF と "=end" が出てくると処理が終了します。
|
168
|
+
</p>
|
169
|
+
<h4 id="LABEL-14">無視される行 (ignore)</h4>
|
170
|
+
<p>
|
171
|
+
Lines starting with"#" and "=begin" are ignored.
|
172
|
+
</p>
|
173
|
+
<h4 id="LABEL-15">その他の入力行 (normal)</h4>
|
174
|
+
<p>
|
175
|
+
地の文になります。
|
176
|
+
</p>
|
177
|
+
<h3 id="LABEL-16">その他のルール</h3>
|
178
|
+
|
179
|
+
<ul>
|
180
|
+
<li>"=end"より後の行はすべて無視されます。</li>
|
181
|
+
<li>あなたのオリジナル・ルールを @subs_rules に加えることができます。</li>
|
182
|
+
</ul>
|
183
|
+
<h3 id="LABEL-17">数式の書き方</h3>
|
184
|
+
<p>
|
185
|
+
文章中の2つのドル記号($)で挟まれた部分がTeX形式からMathML形式に変換されます。
|
186
|
+
また、Eq.…/Eq.で挟まれた行も次の例のように処理されます
|
187
|
+
</p>
|
188
|
+
<p>
|
189
|
+
入力:
|
190
|
+
</p>
|
191
|
+
<pre>Mass $m$ can be converted into energy $E$ as
|
192
|
+
Eq. 1
|
193
|
+
E=mc^2.
|
194
|
+
/Eq.
|
195
|
+
</pre>
|
196
|
+
<p>
|
197
|
+
出力:
|
198
|
+
</p>
|
199
|
+
<p>
|
200
|
+
Mass <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>m</mi></math> can be converted into energy <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>E</mi></math> as
|
201
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>
|
202
|
+
<mi>E</mi>
|
203
|
+
<mo>=</mo>
|
204
|
+
<mi>m</mi>
|
205
|
+
<msup>
|
206
|
+
<mi>c</mi>
|
207
|
+
<mn>2</mn>
|
208
|
+
</msup>
|
209
|
+
<mo>.</mo>
|
210
|
+
</math>
|
211
|
+
</p>
|
212
|
+
<h3 id="LABEL-18">図の挿入方法</h3>
|
213
|
+
<p>
|
214
|
+
入力:
|
215
|
+
</p>
|
216
|
+
<pre>Fig. 1 ruby.jpg
|
217
|
+
The is a dummy figure for an example.
|
218
|
+
/Fig.
|
219
|
+
</pre>
|
220
|
+
<p>
|
221
|
+
出力:
|
222
|
+
</p>
|
223
|
+
<div class="figure">
|
224
|
+
<img src="ruby.jpg" alt="ruby.jpg" />
|
225
|
+
<div class="caption">
|
226
|
+
The is a dummy figure for an example.
|
227
|
+
</div>
|
228
|
+
</div>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
|
232
|
+
<div class="slide">
|
233
|
+
<h2 id="LABEL-19">使用方法</h2>
|
234
|
+
<h3 id="LABEL-20">例</h3>
|
235
|
+
<pre>$ ruby ulmul.rb foo.txt
|
236
|
+
$ ruby ulmul.rb --style=style.css --name="John Smith" foo.ulmul > foo.html
|
237
|
+
$ ./ulmul.rb --style=ulmul-slidy.css --javascript=slidy.js \
|
238
|
+
--name="Takeshi Nishimatsu" presentation.txt > presentation.xhtml
|
239
|
+
</pre>
|
240
|
+
<h3 id="LABEL-21">コマンド・ライン・オプション</h3>
|
241
|
+
<h4 id="LABEL-22">-s, --style</h4>
|
242
|
+
<p>
|
243
|
+
スタイルシートのファイル名を指定します。--style=style.css などがよいでしょう。
|
244
|
+
</p>
|
245
|
+
<h4 id="LABEL-23">-n, --name</h4>
|
246
|
+
<p>
|
247
|
+
あなたの名前を指定します。著作権表示に使われます。
|
248
|
+
</p>
|
249
|
+
<h4 id="LABEL-24">-j, --javascript</h4>
|
250
|
+
<p>
|
251
|
+
JavaScriptのファイル名を指定します。
|
252
|
+
</p>
|
253
|
+
<h4 id="LABEL-25">-l, --language</h4>
|
254
|
+
<p>
|
255
|
+
自然言語の種類を指定します。既定値は"en"です。日本語の場合は-l jaとします。
|
256
|
+
</p>
|
257
|
+
<h4 id="LABEL-26">-c, --contents-range</h4>
|
258
|
+
<p>
|
259
|
+
目次の深さを指定します。既定値は"2..3"です。
|
260
|
+
目次が必要なければ-c 3..2とします。
|
261
|
+
</p>
|
262
|
+
<h4 id="LABEL-27">--help</h4>
|
263
|
+
<p>
|
264
|
+
ヘルプ情報が表示されます。
|
265
|
+
</p>
|
266
|
+
</div>
|
267
|
+
|
268
|
+
|
269
|
+
<div class="slide">
|
270
|
+
<h2 id="LABEL-28">ulmul.rbの仕組み</h2>
|
271
|
+
<p>
|
272
|
+
入力の各行をイベントとして状態遷移しています。
|
273
|
+
class Ulmulの中の定数TABLEが状態遷移表です。
|
274
|
+
これが正しい実装方法なのかよくわかりません。
|
275
|
+
たぶんオートマトンとかを勉強した方がよいのだと思います。
|
276
|
+
</p>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
<div class="slide">
|
281
|
+
<h2 id="LABEL-29">著作権表示</h2>
|
282
|
+
<p>
|
283
|
+
ulmul.rb is distributed in the hope that
|
284
|
+
it will be useful, but WITHOUT ANY WARRANTY.
|
285
|
+
You can copy, modify and redistribute ulmul.rb,
|
286
|
+
but only under the conditions described in
|
287
|
+
the GNU General Public License (the "GPL").
|
288
|
+
</p>
|
289
|
+
<p>
|
290
|
+
W3C has copyrights for slidy.js and ulmul-slidy.css (originally
|
291
|
+
named slidy.css). Takeshi Nishimatsu modified them.
|
292
|
+
You can download the original package, slidy.zip, from
|
293
|
+
<a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> . You can find
|
294
|
+
their licenses at <a href="http://www.w3.org/Consortium/Legal/copyright-documents">http://www.w3.org/Consortium/Legal/copyright-documents</a>
|
295
|
+
and <a href="http://www.w3.org/Consortium/Legal/copyright-software">http://www.w3.org/Consortium/Legal/copyright-software</a> .
|
296
|
+
</p>
|
297
|
+
</div>
|
298
|
+
|
299
|
+
|
300
|
+
<div class="slide">
|
301
|
+
<h2 id="LABEL-30">作者</h2>
|
302
|
+
<p>
|
303
|
+
西松タケシ (t_nissie{at}yahoo.co.jp)
|
304
|
+
</p>
|
305
|
+
</div>
|
306
|
+
</body>
|
307
|
+
</html>
|
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
#! /usr/bin/env rake
|
2
|
+
# -*-Ruby-*-
|
3
|
+
# Time-stamp: <2009-01-04 11:56:08 takeshi>
|
4
|
+
# Author: Takeshi Nishimatsu
|
5
|
+
##
|
6
|
+
$LOAD_PATH.unshift('lib')
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rake/gempackagetask'
|
10
|
+
require 'rake/testtask'
|
11
|
+
require 'rake/clean'
|
12
|
+
require 'ulmul.rb'
|
13
|
+
require 'archive/tar/minitar'
|
14
|
+
require 'zlib'
|
15
|
+
|
16
|
+
spec = eval(File.read("ulmul.gemspec"))
|
17
|
+
spec.version = ULMUL_RB_VERSION
|
18
|
+
ULMUL_PACKAGE_DIR = '..'
|
19
|
+
# RDOC_OPTS = %w(--title ulmul --line-numbers)
|
20
|
+
# spec.rdoc_options = RDOC_OPTS
|
21
|
+
# CLEAN.include('html')
|
22
|
+
|
23
|
+
desc "Build a gem for ulmul"
|
24
|
+
task :gem => [ :test ]
|
25
|
+
Rake::GemPackageTask.new(spec) do |g|
|
26
|
+
g.need_tar = true
|
27
|
+
g.need_zip = true
|
28
|
+
g.package_dir = ULMUL_PACKAGE_DIR
|
29
|
+
end
|
30
|
+
|
31
|
+
task :default => [ :test ]
|
32
|
+
|
33
|
+
desc "Run the unit and functional tests"
|
34
|
+
task :test
|
35
|
+
Rake::TestTask.new do |t|
|
36
|
+
t.test_files = FileList['tests/*.rb']
|
37
|
+
t.verbose = true
|
38
|
+
end
|
39
|
+
|
40
|
+
# Rake::RDocTask.new do |rdoc|
|
41
|
+
# rdoc.rdoc_dir = 'html'
|
42
|
+
# rdoc.options = RDOC_OPTS
|
43
|
+
# if ENV['DOC_FILES']
|
44
|
+
# rdoc.rdoc_files.include(ENV['DOC_FILES'].split(/,\s*/))
|
45
|
+
# else
|
46
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
|
50
|
+
desc "Publish to RubyForge"
|
51
|
+
task :rubyforge => ["README-en.xhtml",
|
52
|
+
"README-ja.xhtml",
|
53
|
+
"style.css", "index.html", "favicon.ico", "ruby.jpg"] do |t|
|
54
|
+
t.prerequisites.each do |f|
|
55
|
+
sh "scp #{f} t-nissie@rubyforge.org:/var/www/gforge-projects/ulmul/"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Build Packages"
|
60
|
+
task :package => [ :ulmul_version_rb ]
|
61
|
+
|
62
|
+
desc "Copy lib/ulmul.rb ../ulmul-X.Y.Z.rb"
|
63
|
+
task :ulmul_version_rb do
|
64
|
+
FileUtils.copy_file('lib/ulmul.rb', ULMUL_PACKAGE_DIR + '/ulmul-' + ULMUL_RB_VERSION + '.rb')
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Create README-en.xhtml"
|
68
|
+
file "README-en.xhtml" => ["bin/ulmul.rb", "style.css", "lib/ulmul.rb"] do |t|
|
69
|
+
sh "ruby #{t.prerequisites[0]} -c 2..3 -s #{t.prerequisites[1]} #{t.prerequisites[2]} > #{t.name}"
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "Create README-ja.xhtml"
|
73
|
+
file "README-ja.xhtml" => ["bin/ulmul.rb", "style.css", "README-ja"] do |t|
|
74
|
+
sh "ruby #{t.prerequisites[0]} -c 2..3 -s #{t.prerequisites[1]} #{t.prerequisites[2]} > #{t.name}"
|
75
|
+
end
|
data/bin/ulmul.rb
ADDED
@@ -0,0 +1,561 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ulmul.rb
|
3
|
+
# Time-stamp: <2009-01-04 15:52:34 takeshi>
|
4
|
+
# Author: Takeshi Nishimatsu
|
5
|
+
##
|
6
|
+
=begin
|
7
|
+
= ULMUL (ulmul.rb)
|
8
|
+
ULMUL (ulmul.rb) is a converter from Ultra Lightweight MarkUp Language to
|
9
|
+
(X)HTML. You can create HTML files, Slidy HTML files and MathML XHTML
|
10
|
+
files very easily.
|
11
|
+
|
12
|
+
The author is using ULMUL to generate his web pages.
|
13
|
+
http://loto.sourceforge.net/feram/ is converted from
|
14
|
+
http://loto.sourceforge.net/feram/README .
|
15
|
+
http://loto.sourceforge.net/feram/doc/film.xhtml is converted from
|
16
|
+
http://loto.sourceforge.net/feram/doc/film.txt .
|
17
|
+
|
18
|
+
== Where is the homepage of ULMUL?
|
19
|
+
http://ulmul.rubyforge.org/
|
20
|
+
|
21
|
+
== Where can I download ulmul.rb?
|
22
|
+
Go to http://rubyforge.org/projects/ulmul .
|
23
|
+
|
24
|
+
== How can I install ULMUL?
|
25
|
+
There are two different ways to install ULMUL.
|
26
|
+
=== I. Conservative way; use setup.rb
|
27
|
+
ulmul-X.Y.Z.tgz package can be installed as:
|
28
|
+
$ tar zxf ulmul-X.Y.Z.tgz
|
29
|
+
$ cd ulmul-X.Y.Z
|
30
|
+
$ su
|
31
|
+
# ruby setup.rb
|
32
|
+
Note that the eimxml and mathml libraries are required.
|
33
|
+
=== II. RubyGems users can take an easy way
|
34
|
+
There is an easy way, if you are a RubyGems user:
|
35
|
+
$ su
|
36
|
+
# gem install ulmul
|
37
|
+
If you do not have the eimxml and mathml libraries, gem will download and install the
|
38
|
+
library automatically.
|
39
|
+
|
40
|
+
=== Files
|
41
|
+
* ulmul.rb Ruby script.
|
42
|
+
* slidy.js JavaScript for Slidy. Slightly modified from the original.
|
43
|
+
* ulmul-slidy.css CSS file for Slidy. Largely modified from the original.
|
44
|
+
* style.css Example CSS file for normal web pages.
|
45
|
+
If you installed ULMUL with gem, you may find these files in
|
46
|
+
/usr/local/lib/ruby/gems/1.8/gems/ulmul-X.Y.Z/
|
47
|
+
or /usr/lib/ruby/gems/1.8/gems/ulmul-X.Y.Z/ .
|
48
|
+
|
49
|
+
== How can I write a ULMUL text?
|
50
|
+
The encode of input file must be utf-8.
|
51
|
+
=== Events (each input line)
|
52
|
+
==== empty
|
53
|
+
Empty lines devide paragraphs.
|
54
|
+
==== heading
|
55
|
+
Starting with "= ", "== ", "=== ", "==== ", "===== ", and "====== ".
|
56
|
+
"= " will be used for the title.
|
57
|
+
==== asterisk
|
58
|
+
Lines starting with
|
59
|
+
" *"
|
60
|
+
" *"
|
61
|
+
" *"
|
62
|
+
" *"
|
63
|
+
" *"
|
64
|
+
become itemize.
|
65
|
+
==== offset
|
66
|
+
Lines starting with some spaces but not asterisks become verbatim lines.
|
67
|
+
==== end
|
68
|
+
EOF or "=end" end the process.
|
69
|
+
==== ignore
|
70
|
+
Lines starting with"#" and "=begin" are ignored.
|
71
|
+
==== normal
|
72
|
+
Other lines.
|
73
|
+
=== Other rules
|
74
|
+
* Lines after "=end" are ignored.
|
75
|
+
* Add your substitution rules to @subs_rules.
|
76
|
+
=== Equations
|
77
|
+
Input:
|
78
|
+
Mass $m$ can be converted into energy $E$ as
|
79
|
+
Eq. 1
|
80
|
+
E=mc^2.
|
81
|
+
/Eq.
|
82
|
+
|
83
|
+
Output:
|
84
|
+
|
85
|
+
Mass $m$ can be converted into energy $E$ as
|
86
|
+
Eq. 1
|
87
|
+
E=mc^2.
|
88
|
+
/Eq.
|
89
|
+
|
90
|
+
=== Figures
|
91
|
+
Input:
|
92
|
+
Fig. 1 ruby.jpg
|
93
|
+
The is a dummy figure for an example.
|
94
|
+
/Fig.
|
95
|
+
|
96
|
+
Output:
|
97
|
+
Fig. 1 ruby.jpg
|
98
|
+
The is a dummy figure for an example.
|
99
|
+
/Fig.
|
100
|
+
|
101
|
+
|
102
|
+
== Usage
|
103
|
+
=== Examples
|
104
|
+
% ruby ulmul.rb foo.txt
|
105
|
+
% ruby ulmul.rb --style=style.css --name="John Smith" foo.ulmul > foo.html
|
106
|
+
% ./ulmul.rb --style=ulmul-slidy.css --javascript=slidy.js \
|
107
|
+
--name="Takeshi Nishimatsu" presentation.txt > presentation.xhtml
|
108
|
+
=== Command options
|
109
|
+
==== -s, --style
|
110
|
+
Specify stylesheet filename.
|
111
|
+
==== -n, --name
|
112
|
+
Specify your name for copyright notices.
|
113
|
+
==== -j, --javascript
|
114
|
+
Specify JavaScript filename.
|
115
|
+
==== -l, --language
|
116
|
+
Specify natural language. Its default is "en".
|
117
|
+
==== -c, --contents-range
|
118
|
+
Range of "Contents". Its default is "2..3".
|
119
|
+
If you do not need "Contents" at the beginning of the
|
120
|
+
output HTML file, set it 3..2.
|
121
|
+
==== --help
|
122
|
+
Show a help message.
|
123
|
+
|
124
|
+
== TODO
|
125
|
+
* rescue syntax errors (raises) in an input file and report the
|
126
|
+
errors as #{$FILENAME}:#{file.lineno}:...
|
127
|
+
* Unit test, tests/ulmul_test.rb
|
128
|
+
* @body must be XML object, not a String.
|
129
|
+
* Tables.
|
130
|
+
* References to figures and tables.
|
131
|
+
* Citation.
|
132
|
+
|
133
|
+
== Copying
|
134
|
+
ulmul.rb is distributed in the hope that
|
135
|
+
it will be useful, but WITHOUT ANY WARRANTY.
|
136
|
+
You can copy, modify and redistribute ulmul.rb,
|
137
|
+
but only under the conditions described in
|
138
|
+
the GNU General Public License (the "GPL").
|
139
|
+
|
140
|
+
W3C has copyrights for slidy.js and ulmul-slidy.css (originally
|
141
|
+
named slidy.css). Takeshi Nishimatsu modified them.
|
142
|
+
You can download the original package, slidy.zip, from
|
143
|
+
http://www.w3.org/Talks/Tools/Slidy/ . You can find
|
144
|
+
their licenses at http://www.w3.org/Consortium/Legal/copyright-documents
|
145
|
+
and http://www.w3.org/Consortium/Legal/copyright-software .
|
146
|
+
|
147
|
+
== Author of ULMUL
|
148
|
+
Takeshi Nishimatsu (t_nissie{at}yahoo.co.jp)
|
149
|
+
|
150
|
+
=end
|
151
|
+
require "rubygems"
|
152
|
+
require "date"
|
153
|
+
require "math_ml/string"
|
154
|
+
ULMUL_RB_VERSION = '0.1.0'
|
155
|
+
CONTENTS_RANGE_DEFAULT=2..3
|
156
|
+
|
157
|
+
class String
|
158
|
+
def apply_subs_rules(rules)
|
159
|
+
result = self.dup
|
160
|
+
rules.each do |ary|
|
161
|
+
result.gsub!(ary[0],ary[1])
|
162
|
+
end
|
163
|
+
is_mathml = false
|
164
|
+
while result =~ /\$(.*?)\$/
|
165
|
+
pre=$`
|
166
|
+
tex=Regexp.last_match[1]
|
167
|
+
post=$'
|
168
|
+
result = "#{pre}#{tex.to_mathml}#{post}"
|
169
|
+
is_mathml = true
|
170
|
+
end
|
171
|
+
return result, is_mathml
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
module Itemize
|
176
|
+
def itemize_begin(e)
|
177
|
+
@level_of_state = 0
|
178
|
+
end
|
179
|
+
|
180
|
+
def itemize_add_primitive(new_level,str)
|
181
|
+
if new_level>@level_of_state+1
|
182
|
+
raise 'Illegal jump of itemize level'
|
183
|
+
elsif new_level==@level_of_state+1
|
184
|
+
@body << "\n" << " "*@level_of_state << "<ul>\n"
|
185
|
+
@body << " "*(new_level-1) << " " << "<li>#{str}"
|
186
|
+
@level_of_state = new_level
|
187
|
+
elsif new_level==@level_of_state
|
188
|
+
@body << "</li>\n" << " "*(new_level-1) << " " << "<li>#{str}"
|
189
|
+
else
|
190
|
+
@body << "</li>\n"
|
191
|
+
(@level_of_state-1).downto(new_level){|i| @body << " "*i << "</ul></li>\n"}
|
192
|
+
@body << " "*(new_level-1) << " " << "<li>#{str}"
|
193
|
+
@level_of_state = new_level
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def itemize_continue_primitive(new_level,str)
|
198
|
+
(@level_of_state-1).downto(new_level){|i| @body << "</li>\n" << " "*i << "</ul>"}
|
199
|
+
@body << "\n " << " "*(new_level-1) << " " << str
|
200
|
+
@level_of_state = new_level
|
201
|
+
end
|
202
|
+
|
203
|
+
def itemize_end(e)
|
204
|
+
@body << "</li>\n"
|
205
|
+
(@level_of_state-1).downto(1){|i| @body << " "*i << "</ul></li>\n"}
|
206
|
+
@body << "</ul>\n"
|
207
|
+
@level_of_state = 0
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
class Contents
|
212
|
+
include Itemize
|
213
|
+
def initialize()
|
214
|
+
@state = 'itemize'
|
215
|
+
@level_of_state = 0
|
216
|
+
@body = ''
|
217
|
+
end
|
218
|
+
attr_reader :body
|
219
|
+
end
|
220
|
+
|
221
|
+
class Ulmul
|
222
|
+
CONTENTS_HERE="<!-- Contents -->"
|
223
|
+
TABLE={
|
224
|
+
'ignore' => {'ground' => [],
|
225
|
+
'itemize' => [],
|
226
|
+
'verbatim' => [],
|
227
|
+
'paragraph' => [],
|
228
|
+
'equation' => [],
|
229
|
+
'figure' => []},
|
230
|
+
|
231
|
+
'end' => {'ground' => [ :heading_add],
|
232
|
+
'itemize' => [ :itemize_end, :heading_add, 'ground'],
|
233
|
+
'verbatim' => [ :verbatim_end, :heading_add, 'ground'],
|
234
|
+
'paragraph' => [:paragraph_end, :heading_add, 'ground'],
|
235
|
+
'equation' => [:equation_error],
|
236
|
+
'figure' => [:figure_error]},
|
237
|
+
|
238
|
+
'heading' => {'ground' => [ :heading_add],
|
239
|
+
'itemize' => [ :itemize_end, :heading_add, 'ground'],
|
240
|
+
'verbatim' => [ :verbatim_end, :heading_add, 'ground'],
|
241
|
+
'paragraph' => [:paragraph_end, :heading_add, 'ground'],
|
242
|
+
'equation' => [:equation_continue],
|
243
|
+
'figure' => [:figure_continue]},
|
244
|
+
|
245
|
+
'asterisk' => {'ground' => [:itemize_begin, 'itemize', :itemize_add],
|
246
|
+
'itemize' => [ :itemize_add],
|
247
|
+
'verbatim' => [ :verbatim_add],
|
248
|
+
'paragraph' => [:paragraph_end,
|
249
|
+
:itemize_begin, 'itemize', :itemize_add],
|
250
|
+
'equation' => [:equation_continue],
|
251
|
+
'figure' => [:figure_continue]},
|
252
|
+
|
253
|
+
'offset' => {'ground' => [:verbatim_begin, 'verbatim', :verbatim_add],
|
254
|
+
'itemize' => [:itemize_continue],
|
255
|
+
'verbatim' => [ :verbatim_add],
|
256
|
+
'paragraph' => [:paragraph_end,
|
257
|
+
:verbatim_begin, 'verbatim', :verbatim_add],
|
258
|
+
'equation' => [:equation_continue],
|
259
|
+
'figure' => [:figure_continue]},
|
260
|
+
|
261
|
+
'empty' => {'ground' => [],
|
262
|
+
'itemize' => [:itemize_end, 'ground'],
|
263
|
+
'verbatim' => [:verbatim_add],
|
264
|
+
'paragraph' => [:paragraph_end, 'ground'],
|
265
|
+
'equation' => [:equation_error],
|
266
|
+
'figure' => [:figure_error]},
|
267
|
+
|
268
|
+
'normal' => {'ground' => [:paragraph_begin, 'paragraph', :paragraph_add],
|
269
|
+
'itemize' => [:itemize_end,
|
270
|
+
:paragraph_begin, 'paragraph', :paragraph_add],
|
271
|
+
'verbatim' => [:verbatim_end,
|
272
|
+
:paragraph_begin, 'paragraph', :paragraph_add],
|
273
|
+
'paragraph' => [:paragraph_add],
|
274
|
+
'equation' => [:equation_continue],
|
275
|
+
'figure' => [:figure_continue]},
|
276
|
+
|
277
|
+
'eq_begin' => {'ground' => [:paragraph_begin, :equation_begin, 'equation'],
|
278
|
+
'itemize' => [:itemize_end,
|
279
|
+
:paragraph_begin, :equation_begin, 'equation'],
|
280
|
+
'verbatim' => [:verbatim_end,
|
281
|
+
:paragraph_begin, :equation_begin, 'equation'],
|
282
|
+
'paragraph' => [ :equation_begin, 'equation'],
|
283
|
+
'equation' => [:equation_error],
|
284
|
+
'figure' => [:figure_error]},
|
285
|
+
|
286
|
+
'eq_end' => {'ground' => [:equation_error],
|
287
|
+
'itemize' => [:equation_error],
|
288
|
+
'verbatim' => [:equation_error],
|
289
|
+
'paragraph' => [:equation_error],
|
290
|
+
'equation' => [:equation_end, 'paragraph'],
|
291
|
+
'figure' => [:figure_error]},
|
292
|
+
|
293
|
+
'fig_begin'=> {'ground' => [ :figure_begin, 'figure'],
|
294
|
+
'itemize' => [:itemize_end, :figure_begin, 'figure'],
|
295
|
+
'verbatim' => [:verbatim_end, :figure_begin, 'figure'],
|
296
|
+
'paragraph' => [:paragraph_end, :figure_begin, 'figure'],
|
297
|
+
'equation' => [:equation_error],
|
298
|
+
'figure' => [:figure_error]},
|
299
|
+
|
300
|
+
'fig_end' => {'ground' => [:figure_error],
|
301
|
+
'itemize' => [:figure_error],
|
302
|
+
'verbatim' => [:figure_error],
|
303
|
+
'paragraph' => [:figure_error],
|
304
|
+
'equation' => [:figure_error],
|
305
|
+
'figure' => [:figure_end, 'ground']}
|
306
|
+
}
|
307
|
+
|
308
|
+
def initialize(contents_range=CONTENTS_RANGE_DEFAULT)
|
309
|
+
@contents_range = contents_range
|
310
|
+
@contents = Contents.new()
|
311
|
+
@state = 'ground'
|
312
|
+
@level_of_state = 0
|
313
|
+
@level_of_heading = 0
|
314
|
+
@i_th_heading = 0
|
315
|
+
@equation = ''
|
316
|
+
@figure_caption = ''
|
317
|
+
@body = ''
|
318
|
+
@subs_rules = [[/(http:\S*)(\s|$)/, '<a href="\1">\1</a>\2'],
|
319
|
+
[/(https:\S*)(\s|$)/, '<a href="\1">\1</a>\2']]
|
320
|
+
@contents.itemize_begin(nil)
|
321
|
+
@is_mathml = false
|
322
|
+
end
|
323
|
+
attr_accessor :subs_rules
|
324
|
+
|
325
|
+
def equation_begin(e)
|
326
|
+
@is_mathml = true
|
327
|
+
end
|
328
|
+
|
329
|
+
def equation_continue(e)
|
330
|
+
@equation << e.line
|
331
|
+
end
|
332
|
+
|
333
|
+
def equation_end(e)
|
334
|
+
@body << @equation.to_mathml('block').to_s << "\n"
|
335
|
+
@equation =''
|
336
|
+
end
|
337
|
+
|
338
|
+
def figure_begin(e)
|
339
|
+
dummy, @figure_label, @figure_file = e.line.split
|
340
|
+
@body << "<div class=\"figure\">
|
341
|
+
<img src=\"#{@figure_file}\" alt=\"#{@figure_file}\" />
|
342
|
+
<div class=\"caption\">\n"
|
343
|
+
end
|
344
|
+
|
345
|
+
def figure_continue(e)
|
346
|
+
result, is_mathml = e.line.apply_subs_rules(@subs_rules)
|
347
|
+
@figure_caption << result
|
348
|
+
@is_mathml = @is_mathml || is_mathml
|
349
|
+
end
|
350
|
+
|
351
|
+
def figure_end(e)
|
352
|
+
@body << @figure_caption << " </div>\n" << "</div>\n"
|
353
|
+
@figure_caption =''
|
354
|
+
end
|
355
|
+
|
356
|
+
def figure_error(e)
|
357
|
+
p e
|
358
|
+
exit 1
|
359
|
+
end
|
360
|
+
|
361
|
+
def verbatim_begin(e)
|
362
|
+
@level_of_state = 0
|
363
|
+
@body << "<pre>"
|
364
|
+
end
|
365
|
+
|
366
|
+
def verbatim_add(e)
|
367
|
+
if e.event=='empty'
|
368
|
+
@level_of_state += 1
|
369
|
+
else
|
370
|
+
@body << "\n"*@level_of_state << e.line[1..-1].gsub(/</,'<').gsub(/>/,'>')
|
371
|
+
@level_of_state=0
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def verbatim_end(e)
|
376
|
+
@body << "</pre>\n"
|
377
|
+
end
|
378
|
+
|
379
|
+
def paragraph_begin(e)
|
380
|
+
@level_of_state = 0
|
381
|
+
@body << "<p>\n"
|
382
|
+
end
|
383
|
+
|
384
|
+
def paragraph_add(e)
|
385
|
+
result, is_mathml = e.line.apply_subs_rules(@subs_rules)
|
386
|
+
@body << result
|
387
|
+
@is_mathml = @is_mathml || is_mathml
|
388
|
+
end
|
389
|
+
|
390
|
+
def paragraph_end(e)
|
391
|
+
@body << "</p>\n"
|
392
|
+
end
|
393
|
+
|
394
|
+
def heading_add(e)
|
395
|
+
if /^(=+) (.*)$/ =~ e.line
|
396
|
+
new_level=Regexp.last_match[1].length
|
397
|
+
str=Regexp.last_match[2]
|
398
|
+
elsif /^=end/ =~ e.line
|
399
|
+
@level_of_heading=0
|
400
|
+
@body << '</div>'
|
401
|
+
@contents.itemize_end(nil)
|
402
|
+
return
|
403
|
+
end
|
404
|
+
raise 'Illegal jump of heading level' if new_level>@level_of_heading+1
|
405
|
+
@i_th_heading += 1
|
406
|
+
@body << CONTENTS_HERE << "\n" if @i_th_heading==2
|
407
|
+
@body << "</div>\n\n\n" if @i_th_heading!=1 and new_level<=2
|
408
|
+
@title=str if @i_th_heading==1
|
409
|
+
cls = case new_level
|
410
|
+
when 1 then "slide cover"
|
411
|
+
else "slide"
|
412
|
+
end
|
413
|
+
@body << "<div class=\"#{cls}\">\n" if new_level<=2
|
414
|
+
@body << "<h#{new_level} id=\"LABEL-#{@i_th_heading}\">" << str << "</h#{new_level}>\n"
|
415
|
+
if @contents_range === new_level
|
416
|
+
@contents.itemize_add_primitive(1+new_level-@contents_range.first,
|
417
|
+
"<a href=\"#LABEL-#{@i_th_heading}\">" + str + "</a>")
|
418
|
+
end
|
419
|
+
@level_of_heading=new_level
|
420
|
+
end
|
421
|
+
|
422
|
+
include Itemize
|
423
|
+
def itemize_add(e)
|
424
|
+
new_level = case e.line
|
425
|
+
when /^ \* (.*)/ then 1
|
426
|
+
when /^ \* (.*)/ then 2
|
427
|
+
when /^ \* (.*)/ then 3
|
428
|
+
when /^ \* (.*)/ then 4
|
429
|
+
when /^ \* (.*)/ then 5
|
430
|
+
else raise 'Illegal astarisk line for itemize'
|
431
|
+
end
|
432
|
+
str, is_mathml = Regexp.last_match[1].apply_subs_rules(@subs_rules)
|
433
|
+
itemize_add_primitive(new_level,str)
|
434
|
+
@is_mathml = @is_mathml || is_mathml
|
435
|
+
end
|
436
|
+
def itemize_continue(e)
|
437
|
+
/^(\s+)(\S.*)$/.match(e.line)
|
438
|
+
new_level = Regexp.last_match[1].length/2
|
439
|
+
new_level=@level_of_state if new_level>@level_of_state
|
440
|
+
raise "Illegal indent in itemize" if new_level<=0
|
441
|
+
str, is_mathml = Regexp.last_match[2].apply_subs_rules(@subs_rules)
|
442
|
+
itemize_continue_primitive(new_level,str)
|
443
|
+
@is_mathml = @is_mathml || is_mathml
|
444
|
+
end
|
445
|
+
|
446
|
+
|
447
|
+
def parse(fd)
|
448
|
+
while line=fd.gets || line="=end\n"
|
449
|
+
e = Event.new(line)
|
450
|
+
#STDERR.printf("%s\n", @state)
|
451
|
+
#STDERR.printf("%-10s:%s", e.event, line)
|
452
|
+
procs = TABLE[e.event][@state]
|
453
|
+
procs.each do |i|
|
454
|
+
send(i,e) if i.instance_of?(Symbol)
|
455
|
+
@state=i if i.instance_of?(String)
|
456
|
+
end
|
457
|
+
break if e.event=='end'
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def body
|
462
|
+
if @contents_range.first<=@contents_range.last
|
463
|
+
@body.sub(CONTENTS_HERE,"<br />Contents:"+@contents.body)
|
464
|
+
else
|
465
|
+
@body
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
def html(stylesheets=["style.css"],javascripts=[],name="",language="en")
|
470
|
+
style_lines=""
|
471
|
+
stylesheets.each{|s| style_lines << "<link rel=\"stylesheet\" href=\"#{s}\" type=\"text/css\" />\n"}
|
472
|
+
javascript_lines=""
|
473
|
+
javascripts.each{|j| javascript_lines << "<script src=\"#{j}\" type=\"text/javascript\"></script>\n"}
|
474
|
+
if @is_mathml
|
475
|
+
doctype_lines='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
|
476
|
+
"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">'
|
477
|
+
html_line="<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language}\" dir=\"ltr\">"
|
478
|
+
else
|
479
|
+
doctype_lines='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
480
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
481
|
+
html_line="<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language}\" lang=\"#{language}\" dir=\"ltr\">"
|
482
|
+
end
|
483
|
+
return "<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
484
|
+
#{doctype_lines}
|
485
|
+
|
486
|
+
#{html_line}
|
487
|
+
<head>
|
488
|
+
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
|
489
|
+
<title>#{@title}</title>
|
490
|
+
<meta name=\"author\" content=\"#{name}\" />
|
491
|
+
<meta name=\"copyright\" content=\"Copyright © #{Date.today.year} #{name}\" />
|
492
|
+
#{style_lines}#{javascript_lines}<link rel=\"shortcut icon\" href=\"favicon.ico\" />
|
493
|
+
</head>
|
494
|
+
<body>
|
495
|
+
#{body()}
|
496
|
+
</body>
|
497
|
+
</html>
|
498
|
+
"
|
499
|
+
end
|
500
|
+
|
501
|
+
class Event
|
502
|
+
attr_reader :line, :event
|
503
|
+
def initialize(line)
|
504
|
+
@line = line
|
505
|
+
@event = case line
|
506
|
+
when /^=begin/,/^#/ then 'ignore'
|
507
|
+
when /^=end/ then 'end'
|
508
|
+
when /^=+ / then 'heading'
|
509
|
+
when /^ +\*/ then 'asterisk'
|
510
|
+
when /^\s*$/ then 'empty'
|
511
|
+
when /^\s+/ then 'offset'
|
512
|
+
when /^Eq\./ then 'eq_begin'
|
513
|
+
when /^\/Eq/ then 'eq_end'
|
514
|
+
when /^Fig\./ then 'fig_begin'
|
515
|
+
when /^\/Fig/ then 'fig_end'
|
516
|
+
else 'normal'
|
517
|
+
end
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
if $0 == __FILE__
|
523
|
+
require "optparse"
|
524
|
+
name = ENV['USER'] || ENV['LOGNAME'] || Etc.getlogin || Etc.getpwuid.name
|
525
|
+
language = "en"
|
526
|
+
stylesheets = []
|
527
|
+
javascripts = []
|
528
|
+
contents_range = CONTENTS_RANGE_DEFAULT
|
529
|
+
opts = OptionParser.new
|
530
|
+
def opts.usage
|
531
|
+
return to_s.sub(/options/,'options] [filename')
|
532
|
+
end
|
533
|
+
opts.on("-s STYLESHEET_FILENAME","--style STYLESHEET_FILENAME",
|
534
|
+
"Specify stylesheet filename."){|v| stylesheets<<v}
|
535
|
+
opts.on("-n YOUR_NAME","--name YOUR_NAME","Specify your name."){|v| name=v}
|
536
|
+
opts.on("-j JAVASCRIPT_FILENAME","--javascript JAVASCRIPT_FILENAME",
|
537
|
+
"Specify JavaScript filename."){|v| javascripts<<v}
|
538
|
+
opts.on("-l LANGUAGE","--language LANGUAGE",String,
|
539
|
+
"Specify natural language. Its defalt is 'en'."){|v| language=v[0..1].downcase}
|
540
|
+
opts.on("-c CONTENTS_RANGE","--contents-range RANGE_OF_CONTENTS_RANGE","Range of Contents."){|v|
|
541
|
+
begin
|
542
|
+
if eval(v).instance_of?(Range)
|
543
|
+
contents_range=eval(v)
|
544
|
+
else
|
545
|
+
raise NameError
|
546
|
+
end
|
547
|
+
rescue NameError
|
548
|
+
raise("Cannot evaluate given \"#{v}\" as a Range")
|
549
|
+
end
|
550
|
+
}
|
551
|
+
opts.on_tail("-h", "--help", "Show this message."){puts opts.usage; exit}
|
552
|
+
|
553
|
+
opts.parse!(ARGV)
|
554
|
+
|
555
|
+
u=Ulmul.new(contents_range)
|
556
|
+
u.parse(ARGF)
|
557
|
+
puts u.html(stylesheets,javascripts,name,language)
|
558
|
+
end
|
559
|
+
# Local variables:
|
560
|
+
# compile-command: "./ulmul.rb -c 2..3 -s style.css ulmul.rb > ../README-en.xhtml && ./ulmul.rb -c 2..3 -s style.css ../README-ja > ../README-ja.xhtml"
|
561
|
+
# End:
|