ulmul 0.1.0 → 0.3.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.
@@ -1,37 +1,29 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
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">
3
+ "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" dir="ltr">
6
5
  <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 &#169; 2009 takeshi" />
11
- <link rel="stylesheet" href="style.css" type="text/css" />
12
- <link rel="shortcut icon" href="favicon.ico" />
6
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
7
+ <title>ULMUL取扱説明書</title>
8
+ <meta name="author" content="Takeshi Nishimatsu" />
9
+ <meta name="copyright" content="Copyright &#169; 2010 Takeshi Nishimatsu" />
10
+ <link rel="stylesheet" href="ulmul2xhtml.css" type="text/css" />
11
+ <link rel="shortcut icon" href="favicon.ico" />
13
12
  </head>
14
13
  <body>
15
14
  <div class="slide cover">
16
- <h1 id="LABEL-1">ULMUL (ulmul.rb) 取扱説明書</h1>
15
+ <h1 id="LABEL-1">ULMUL取扱説明書</h1>
17
16
  <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
- と同様なことができるようになることをめざして開発しています。
17
+ ULMULは独自の軽量マークアップ言語 (Ultra Lightweight MarkUp Language) です。
18
+ コマンドulmul2html5でHTML5に、ulmul2xhtmlでXHTMLに変換できます。
19
+ 文章中のTeXスタイルで書かれた数式をMathMLに変換できるのが特徴です。
20
+ Rubyで書かれています。ulmul.rbをライブラリとして利用することも可能です。
24
21
  </p>
25
22
  <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> から関連するファイルをダウンロードすることができます。
23
+ ホームページ: <a href="http://ulmul.rubyforge.org/">http://ulmul.rubyforge.org/</a>
28
24
  </p>
29
25
  <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> から生成されました。
26
+ ダウンロード: <a href="http://rubyforge.org/projects/ulmul/">http://rubyforge.org/projects/ulmul/</a> または <a href="http://rubygems.org/gems/ulmul">http://rubygems.org/gems/ulmul</a>
35
27
  </p>
36
28
  <br />Contents:
37
29
  <ul>
@@ -41,22 +33,23 @@ sourceforge.jpのWikiシンタックス <a href="http://sourceforge.jp/projects/
41
33
  <li><a href="#LABEL-4">I. setup.rbを使う方法</a></li>
42
34
  <li><a href="#LABEL-5">II. RubyGemsを使えば簡単にインストールができます</a></li>
43
35
  </ul></li>
44
- <li><a href="#LABEL-6">必要なファイル</a></li>
45
- <li><a href="#LABEL-7">ULMULテキストの書き方</a>
36
+ <li><a href="#LABEL-6">ULMULテキストの書き方</a>
46
37
  <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>
38
+ <li><a href="#LABEL-7">各行の種類</a></li>
39
+ <li><a href="#LABEL-15">その他のルール</a></li>
40
+ <li><a href="#LABEL-16">数式の書き方</a></li>
41
+ <li><a href="#LABEL-17">図の挿入方法</a></li>
51
42
  </ul></li>
52
- <li><a href="#LABEL-19">使用方法</a>
43
+ <li><a href="#LABEL-18">使用方法</a>
53
44
  <ul>
54
- <li><a href="#LABEL-20">例</a></li>
55
- <li><a href="#LABEL-21">コマンド・ライン・オプション</a></li>
45
+ <li><a href="#LABEL-19">例</a></li>
46
+ <li><a href="#LABEL-20">コマンド・ライン・オプション</a></li>
47
+ <li><a href="#LABEL-27">使用例</a></li>
56
48
  </ul></li>
57
49
  <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>
50
+ <li><a href="#LABEL-29">最新のソース・ツリーの入手方法</a></li>
51
+ <li><a href="#LABEL-30">著作権表示</a></li>
52
+ <li><a href="#LABEL-31">作者</a></li>
60
53
  </ul>
61
54
 
62
55
  </div>
@@ -69,14 +62,13 @@ sourceforge.jpのWikiシンタックス <a href="http://sourceforge.jp/projects/
69
62
  <li>文章中の2つのドル記号($)で挟まれた部分とEq.…/Eq.で挟まれた行が数式としてTeX形式からMathML形式に変換されます。
70
63
  MathMLとはXMLで数式を記述するための規格です。込み入った規格なので人間が直接MathMLを記述する
71
64
  ことは想定されていませんが、ULMULでやっているようにTeXなどからの変換により生成することができます。
72
- Firefoxのバージョン3.0以上で読めるようです。
65
+ Firefoxのバージョン3.0以上やIE+MathPlayerで読めるようです。
73
66
  math_ml.rb <a href="http://www.hinet.mydns.jp/?mathml.rb">http://www.hinet.mydns.jp/?mathml.rb</a> を使っています。</li>
74
67
  <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>
68
+ Slidy <a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> に対応したxhtmlが出力可能。</li>
77
69
  <li>=begin, =end はあってもなくてもかまいません。</li>
78
70
  <li>行を#ではじめるとコメントになります。</li>
79
- <li>ライブラリとしても使えます。</li>
71
+ <li>ulmul.rbをライブラリとしても使えます。</li>
80
72
  <li>subs_rulesに俺ルールを加えることができます。</li>
81
73
  <li>目次 (Contents) を自動的に生成できます。</li>
82
74
  <li>はじめの「= ABCD EFGH」がタイトルになります。Slidyの表紙にもなります。</li>
@@ -99,8 +91,7 @@ sourceforge.jpのWikiシンタックス <a href="http://sourceforge.jp/projects/
99
91
  </p>
100
92
  <pre> $ tar zxf ulmul-X.Y.Z.tgz
101
93
  $ cd ulmul-X.Y.Z
102
- $ su
103
- # ruby setup.rb
94
+ $ sudo ruby setup.rb
104
95
  </pre>
105
96
  <p>
106
97
  なお、ULMULを使うにはeimxmlライブラリとmathmlライブラリとが必要です。
@@ -109,46 +100,27 @@ sourceforge.jpのWikiシンタックス <a href="http://sourceforge.jp/projects/
109
100
  <p>
110
101
  gemでインストールすればeimxmlライブラリとmathmlライブラリとは自動的にインストールされます:
111
102
  </p>
112
- <pre> $ su
113
- # gem install ulmul
103
+ <pre> $ sudo gem install ulmul
114
104
  </pre>
115
105
  </div>
116
106
 
117
107
 
118
108
  <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>
109
+ <h2 id="LABEL-6">ULMULテキストの書き方</h2>
138
110
  <p>
139
111
  ULMULテキストのエンコーディングにはutf-8を使ってください。
140
112
  </p>
141
- <h3 id="LABEL-8">各行の種類</h3>
142
- <h4 id="LABEL-9">空行 (empty)</h4>
113
+ <h3 id="LABEL-7">各行の種類</h3>
114
+ <h4 id="LABEL-8">空行 (empty)</h4>
143
115
  <p>
144
116
  空行は段落を分割します。
145
117
  </p>
146
- <h4 id="LABEL-10">ヘディング (heading)</h4>
118
+ <h4 id="LABEL-9">ヘディング (heading)</h4>
147
119
  <p>
148
120
  "= ", "== ", "=== ", "==== ", "===== ", または "====== " で始めてください。
149
121
  「= ABCD EFGH」ならABCD EFGHがタイトルになります。Slidyの表紙にもなります。
150
122
  </p>
151
- <h4 id="LABEL-11">アスタリスクで始まる行は箇条書きになります (asterisk)</h4>
123
+ <h4 id="LABEL-10">アスタリスクで始まる行は箇条書きになります (asterisk)</h4>
152
124
  <p>
153
125
  6段までネストした箇条書きが可能です:
154
126
  </p>
@@ -158,32 +130,32 @@ ULMULテキストのエンコーディングにはutf-8を使ってください
158
130
  " *"
159
131
  " *"
160
132
  </pre>
161
- <h4 id="LABEL-12">オフセットされて書かれた行はそのまま出力 (verbatim, pre) されます (offset)</h4>
133
+ <h4 id="LABEL-11">オフセットされて書かれた行はそのまま出力 (verbatim, pre) されます (offset)</h4>
162
134
  <p>
163
135
  1つスペースを置いて書き始めた行はverbatimになります。
164
136
  </p>
165
- <h4 id="LABEL-13">終わり (end)</h4>
137
+ <h4 id="LABEL-12">終わり (end)</h4>
166
138
  <p>
167
139
  EOF と "=end" が出てくると処理が終了します。
168
140
  </p>
169
- <h4 id="LABEL-14">無視される行 (ignore)</h4>
141
+ <h4 id="LABEL-13">無視される行 (ignore)</h4>
170
142
  <p>
171
143
  Lines starting with"#" and "=begin" are ignored.
172
144
  </p>
173
- <h4 id="LABEL-15">その他の入力行 (normal)</h4>
145
+ <h4 id="LABEL-14">その他の入力行 (normal)</h4>
174
146
  <p>
175
147
  地の文になります。
176
148
  </p>
177
- <h3 id="LABEL-16">その他のルール</h3>
149
+ <h3 id="LABEL-15">その他のルール</h3>
178
150
 
179
151
  <ul>
180
152
  <li>"=end"より後の行はすべて無視されます。</li>
181
153
  <li>あなたのオリジナル・ルールを @subs_rules に加えることができます。</li>
182
154
  </ul>
183
- <h3 id="LABEL-17">数式の書き方</h3>
155
+ <h3 id="LABEL-16">数式の書き方</h3>
184
156
  <p>
185
157
  文章中の2つのドル記号($)で挟まれた部分がTeX形式からMathML形式に変換されます。
186
- また、Eq.…/Eq.で挟まれた行も次の例のように処理されます
158
+ また、Eq.…/Eq.で挟まれた行も次の例のように処理されます。
187
159
  </p>
188
160
  <p>
189
161
  入力:
@@ -209,12 +181,24 @@ Mass <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>m</mi
209
181
  <mo>.</mo>
210
182
  </math>
211
183
  </p>
212
- <h3 id="LABEL-18">図の挿入方法</h3>
184
+ <p>
185
+ 数式を正しくご覧いただくには
186
+ </p>
187
+
188
+ <ul>
189
+ <li>Firefox <a href="http://mozilla.jp/firefox/">http://mozilla.jp/firefox/</a></li>
190
+ <li>IE8 + MathPlayer <a href="http://www.dessci.com/en/products/mathplayer/">http://www.dessci.com/en/products/mathplayer/</a></li>
191
+ </ul>
192
+ <p>
193
+ などのブラウザを試してみて下さい。
194
+ </p>
195
+ <h3 id="LABEL-17">図の挿入方法</h3>
213
196
  <p>
214
197
  入力:
215
198
  </p>
216
199
  <pre>Fig. 1 ruby.jpg
217
200
  The is a dummy figure for an example.
201
+ Cute red logo of Ruby, isn't it?
218
202
  /Fig.
219
203
  </pre>
220
204
  <p>
@@ -222,22 +206,43 @@ Mass <math xmlns='http://www.w3.org/1998/Math/MathML' display='inline'><mi>m</mi
222
206
  </p>
223
207
  <div class="figure">
224
208
  <img src="ruby.jpg" alt="ruby.jpg" />
225
- <div class="caption">
209
+ <div class="figcaption">
226
210
  The is a dummy figure for an example.
211
+ Cute red logo of Ruby, isn't it?
227
212
  </div>
228
213
  </div>
229
214
  </div>
230
215
 
231
216
 
232
217
  <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 &gt; foo.html
237
- $ ./ulmul.rb --style=ulmul-slidy.css --javascript=slidy.js \
238
- --name="Takeshi Nishimatsu" presentation.txt &gt; presentation.xhtml
218
+ <h2 id="LABEL-18">使用方法</h2>
219
+ <p>
220
+ ulmul2xhtmlとulmul2html5の2つのコマンドがあります。
221
+ </p>
222
+ <p>
223
+ 2010年4月現在、ulmul2xhtmlの出力を.htmlの拡張子を持ったファイルにリダイレクトして
224
+ httpサーバからtext/htmlのMIMEタイプで送信されるようにすれば
225
+ いくつかのブラウザが数式を表示してくれるようです。
226
+ 1行目のxml宣言を取るとさらにうまく表示される場合もあります。
227
+ </p>
228
+ <p>
229
+ Firefox3.6でHTML5を表示するには、URLとして about:config を入力して、
230
+ html5.enableをfalseからtrueに変更してください。
231
+ </p>
232
+ <p>
233
+ IE8はMathMLで書かれた数式を含んだHTML5をうまく表示できないようです。
234
+ </p>
235
+ <h3 id="LABEL-19">例</h3>
236
+ <pre>$ ulmul2xhtml without-equations.txt &gt; without-equations.html # XHTML1.0 Transitional
237
+ $ ulmul2xhtml with-equations.txt &gt; with-equations.html # XHTML1.1 + MathML2.0
238
+ $ ulmul2xhtml -n 'Takeshi Nishimatsu' -s ulmul-slidy.css -j slidy.js presentation.txt &gt; presentation.xhtml
239
+ $ ulmul2html5 with-equations.txt &gt; with-equations.html # HTML5
239
240
  </pre>
240
- <h3 id="LABEL-21">コマンド・ライン・オプション</h3>
241
+ <h3 id="LABEL-20">コマンド・ライン・オプション</h3>
242
+ <h4 id="LABEL-21">--help</h4>
243
+ <p>
244
+ ヘルプ情報が表示されます。
245
+ </p>
241
246
  <h4 id="LABEL-22">-s, --style</h4>
242
247
  <p>
243
248
  スタイルシートのファイル名を指定します。--style=style.css などがよいでしょう。
@@ -259,10 +264,18 @@ JavaScriptのファイル名を指定します。
259
264
  目次の深さを指定します。既定値は"2..3"です。
260
265
  目次が必要なければ-c 3..2とします。
261
266
  </p>
262
- <h4 id="LABEL-27">--help</h4>
263
- <p>
264
- ヘルプ情報が表示されます。
265
- </p>
267
+ <h3 id="LABEL-27">使用例</h3>
268
+
269
+ <ul>
270
+ <li><a href="http://loto.sourceforge.net/feram/">http://loto.sourceforge.net/feram/</a>
271
+ <ul>
272
+ <li>ソースは <a href="http://loto.sourceforge.net/feram/README">http://loto.sourceforge.net/feram/README</a></li>
273
+ </ul></li>
274
+ <li><a href="http://loto.sourceforge.net/feram/doc/film.xhtml">http://loto.sourceforge.net/feram/doc/film.xhtml</a>
275
+ <ul>
276
+ <li>ソースは <a href="http://loto.sourceforge.net/feram/doc/film.txt">http://loto.sourceforge.net/feram/doc/film.txt</a></li>
277
+ </ul></li>
278
+ </ul>
266
279
  </div>
267
280
 
268
281
 
@@ -270,15 +283,27 @@ JavaScriptのファイル名を指定します。
270
283
  <h2 id="LABEL-28">ulmul.rbの仕組み</h2>
271
284
  <p>
272
285
  入力の各行をイベントとして状態遷移しています。
273
- class Ulmulの中の定数TABLEが状態遷移表です。
274
- これが正しい実装方法なのかよくわかりません。
275
- たぶんオートマトンとかを勉強した方がよいのだと思います。
286
+ 定数Ulmul::TABLEが状態遷移表です。
287
+ </p>
288
+ </div>
289
+
290
+
291
+ <div class="slide">
292
+ <h2 id="LABEL-29">最新のソース・ツリーの入手方法</h2>
293
+ <p>
294
+ ソース・ツリーはRubyForge.orgのSubversionレポジトリで管理されています。
295
+ svn(1)コマンドを使って
296
+ </p>
297
+ <pre>$ svn co svn://rubyforge.org/var/svn/ulmul/ulmul/trunk ulmul
298
+ </pre>
299
+ <p>
300
+ とcheckoutできます。
276
301
  </p>
277
302
  </div>
278
303
 
279
304
 
280
305
  <div class="slide">
281
- <h2 id="LABEL-29">著作権表示</h2>
306
+ <h2 id="LABEL-30">著作権表示</h2>
282
307
  <p>
283
308
  ulmul.rb is distributed in the hope that
284
309
  it will be useful, but WITHOUT ANY WARRANTY.
@@ -298,7 +323,7 @@ and <a href="http://www.w3.org/Consortium/Legal/copyright-software">http://www.w
298
323
 
299
324
 
300
325
  <div class="slide">
301
- <h2 id="LABEL-30">作者</h2>
326
+ <h2 id="LABEL-31">作者</h2>
302
327
  <p>
303
328
  西松タケシ (t_nissie{at}yahoo.co.jp)
304
329
  </p>
@@ -1,158 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
  # ulmul.rb
3
- # Time-stamp: <2009-01-04 15:52:34 takeshi>
3
+ # Time-stamp: <2010-04-07 17:15:42 takeshi>
4
4
  # Author: Takeshi Nishimatsu
5
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
6
  require "rubygems"
152
7
  require "date"
153
8
  require "math_ml/string"
154
- ULMUL_RB_VERSION = '0.1.0'
155
- CONTENTS_RANGE_DEFAULT=2..3
156
9
 
157
10
  class String
158
11
  def apply_subs_rules(rules)
@@ -219,7 +72,9 @@ class Contents
219
72
  end
220
73
 
221
74
  class Ulmul
75
+ VERSION = '0.3.0'
222
76
  CONTENTS_HERE="<!-- Contents -->"
77
+ CONTENTS_RANGE_DEFAULT=2..3
223
78
  TABLE={
224
79
  'ignore' => {'ground' => [],
225
80
  'itemize' => [],
@@ -305,7 +160,7 @@ class Ulmul
305
160
  'figure' => [:figure_end, 'ground']}
306
161
  }
307
162
 
308
- def initialize(contents_range=CONTENTS_RANGE_DEFAULT)
163
+ def initialize(contents_range=CONTENTS_RANGE_DEFAULT,mode='ulmul2html5')
309
164
  @contents_range = contents_range
310
165
  @contents = Contents.new()
311
166
  @state = 'ground'
@@ -319,6 +174,19 @@ class Ulmul
319
174
  [/(https:\S*)(\s|$)/, '<a href="\1">\1</a>\2']]
320
175
  @contents.itemize_begin(nil)
321
176
  @is_mathml = false
177
+
178
+ @mode=mode
179
+ if @mode=='ulmul2html5'
180
+ @figure_open = '<figure>'
181
+ @figure_close = '</figure>'
182
+ @caption_open = '<figcaption>'
183
+ @caption_close = '</figcaption>'
184
+ else
185
+ @figure_open = '<div class="figure">'
186
+ @figure_close = '</div>'
187
+ @caption_open = '<div class="figcaption">'
188
+ @caption_close = '</div>'
189
+ end
322
190
  end
323
191
  attr_accessor :subs_rules
324
192
 
@@ -337,9 +205,9 @@ class Ulmul
337
205
 
338
206
  def figure_begin(e)
339
207
  dummy, @figure_label, @figure_file = e.line.split
340
- @body << "<div class=\"figure\">
208
+ @body << "#{@figure_open}
341
209
  <img src=\"#{@figure_file}\" alt=\"#{@figure_file}\" />
342
- <div class=\"caption\">\n"
210
+ #{@caption_open}\n"
343
211
  end
344
212
 
345
213
  def figure_continue(e)
@@ -349,7 +217,7 @@ class Ulmul
349
217
  end
350
218
 
351
219
  def figure_end(e)
352
- @body << @figure_caption << " </div>\n" << "</div>\n"
220
+ @body << @figure_caption << " #{@caption_close}\n" << "#{@figure_close}\n"
353
221
  @figure_caption =''
354
222
  end
355
223
 
@@ -471,25 +339,31 @@ class Ulmul
471
339
  stylesheets.each{|s| style_lines << "<link rel=\"stylesheet\" href=\"#{s}\" type=\"text/css\" />\n"}
472
340
  javascript_lines=""
473
341
  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\">"
342
+ if @mode=='ulmul2html5'
343
+ xml_line=''
344
+ meta_charset_line="<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n "
345
+ doctype_lines="<!DOCTYPE html>"
346
+ html_line="<html lang=\"#{language}\">"
478
347
  else
479
- doctype_lines='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
348
+ xml_line="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
349
+ meta_charset_line="<meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=utf-8\" />\n "
350
+ if @is_mathml
351
+ doctype_lines='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
352
+ "http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd">'
353
+ html_line="<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language}\" dir=\"ltr\">"
354
+ else
355
+ doctype_lines='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
480
356
  "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\">"
357
+ html_line="<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"#{language}\" lang=\"#{language}\" dir=\"ltr\">"
358
+ end
482
359
  end
483
- return "<?xml version=\"1.0\" encoding=\"utf-8\"?>
484
- #{doctype_lines}
485
-
360
+ return "#{xml_line}#{doctype_lines}
486
361
  #{html_line}
487
362
  <head>
488
- <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
489
- <title>#{@title}</title>
363
+ #{meta_charset_line}<title>#{@title}</title>
490
364
  <meta name=\"author\" content=\"#{name}\" />
491
365
  <meta name=\"copyright\" content=\"Copyright &#169; #{Date.today.year} #{name}\" />
492
- #{style_lines}#{javascript_lines}<link rel=\"shortcut icon\" href=\"favicon.ico\" />
366
+ #{style_lines}#{javascript_lines} <link rel=\"shortcut icon\" href=\"favicon.ico\" />
493
367
  </head>
494
368
  <body>
495
369
  #{body()}
@@ -518,44 +392,3 @@ class Ulmul
518
392
  end
519
393
  end
520
394
  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: