ulmul 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ # ulmul2html5
3
+ # Time-stamp: <2010-03-30 18:42:10 takeshi>
4
+ # Author: Takeshi Nishimatsu
5
+ ##
6
+ =begin
7
+ = ulmul2html
8
+ == Usage
9
+ === Examples
10
+ % ulmul2html foo.txt
11
+ % ulmul2html --style=style.css --name="John Smith" foo.ulmul > foo.html
12
+ % ulmul2html --style=ulmul-slidy.css --javascript=slidy.js \
13
+ --name="Takeshi Nishimatsu" presentation.txt > presentation.xhtml
14
+ === Command options
15
+ ==== -s, --style
16
+ Specify stylesheet filename.
17
+ ==== -n, --name
18
+ Specify your name for copyright notices.
19
+ ==== -j, --javascript
20
+ Specify JavaScript filename.
21
+ ==== -l, --language
22
+ Specify natural language. Its default is "en".
23
+ ==== -c, --contents-range
24
+ Range of "Contents". Its default is "2..3".
25
+ If you do not need "Contents" at the beginning of the
26
+ output HTML file, set it 3..2.
27
+ ==== --help
28
+ Show a help message.
29
+ =end
30
+ require "ulmul"
31
+ require "optparse"
32
+ name = ENV['USER'] || ENV['LOGNAME'] || Etc.getlogin || Etc.getpwuid.name
33
+ language = "en"
34
+ stylesheets = []
35
+ javascripts = []
36
+ contents_range = Ulmul::CONTENTS_RANGE_DEFAULT
37
+ opts = OptionParser.new
38
+ def opts.usage
39
+ return to_s.sub(/options/,'options] [filename')
40
+ end
41
+ opts.on("-s STYLESHEET_FILENAME","--style STYLESHEET_FILENAME",
42
+ "Specify stylesheet filename."){|v| stylesheets<<v}
43
+ opts.on("-n YOUR_NAME","--name YOUR_NAME","Specify your name."){|v| name=v}
44
+ opts.on("-j JAVASCRIPT_FILENAME","--javascript JAVASCRIPT_FILENAME",
45
+ "Specify JavaScript filename."){|v| javascripts<<v}
46
+ opts.on("-l LANGUAGE","--language LANGUAGE",String,
47
+ "Specify natural language. Its defalt is 'en'."){|v| language=v[0..1].downcase}
48
+ opts.on("-c CONTENTS_RANGE","--contents-range RANGE_OF_CONTENTS_RANGE","Range of Contents."){|v|
49
+ begin
50
+ if eval(v).instance_of?(Range)
51
+ contents_range=eval(v)
52
+ else
53
+ raise NameError
54
+ end
55
+ rescue NameError
56
+ raise("Cannot evaluate given \"#{v}\" as a Range")
57
+ end
58
+ }
59
+ opts.on_tail("-h", "--help", "Show this message."){puts opts.usage; exit}
60
+
61
+ opts.parse!(ARGV)
62
+ stylesheets=['ulmul2html5.css'] if stylesheets==[]
63
+
64
+ u=Ulmul.new(contents_range,'ulmul2html5')
65
+ u.parse(ARGF)
66
+ puts u.html(stylesheets,javascripts,name,language)
67
+
68
+ # Local variables:
69
+ # compile-command: "ruby -I ../lib ./ulmul2html ulmul2html"
70
+ # End:
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ # ulmul2xhtml
3
+ # Time-stamp: <2010-03-30 18:29:39 takeshi>
4
+ # Author: Takeshi Nishimatsu
5
+ ##
6
+ =begin
7
+ = ulmul2html
8
+ == Usage
9
+ === Examples
10
+ % ulmul2html foo.txt
11
+ % ulmul2html --style=style.css --name="John Smith" foo.ulmul > foo.html
12
+ % ulmul2html --style=ulmul-slidy.css --javascript=slidy.js \
13
+ --name="Takeshi Nishimatsu" presentation.txt > presentation.xhtml
14
+ === Command options
15
+ ==== -s, --style
16
+ Specify stylesheet filename.
17
+ ==== -n, --name
18
+ Specify your name for copyright notices.
19
+ ==== -j, --javascript
20
+ Specify JavaScript filename.
21
+ ==== -l, --language
22
+ Specify natural language. Its default is "en".
23
+ ==== -c, --contents-range
24
+ Range of "Contents". Its default is "2..3".
25
+ If you do not need "Contents" at the beginning of the
26
+ output HTML file, set it 3..2.
27
+ ==== --help
28
+ Show a help message.
29
+ =end
30
+ require "ulmul"
31
+ require "optparse"
32
+ name = ENV['USER'] || ENV['LOGNAME'] || Etc.getlogin || Etc.getpwuid.name
33
+ language = "en"
34
+ stylesheets = []
35
+ javascripts = []
36
+ contents_range = Ulmul::CONTENTS_RANGE_DEFAULT
37
+ opts = OptionParser.new
38
+ def opts.usage
39
+ return to_s.sub(/options/,'options] [filename')
40
+ end
41
+ opts.on("-s STYLESHEET_FILENAME","--style STYLESHEET_FILENAME",
42
+ "Specify stylesheet filename."){|v| stylesheets<<v}
43
+ opts.on("-n YOUR_NAME","--name YOUR_NAME","Specify your name."){|v| name=v}
44
+ opts.on("-j JAVASCRIPT_FILENAME","--javascript JAVASCRIPT_FILENAME",
45
+ "Specify JavaScript filename."){|v| javascripts<<v}
46
+ opts.on("-l LANGUAGE","--language LANGUAGE",String,
47
+ "Specify natural language. Its defalt is 'en'."){|v| language=v[0..1].downcase}
48
+ opts.on("-c CONTENTS_RANGE","--contents-range RANGE_OF_CONTENTS_RANGE","Range of Contents."){|v|
49
+ begin
50
+ if eval(v).instance_of?(Range)
51
+ contents_range=eval(v)
52
+ else
53
+ raise NameError
54
+ end
55
+ rescue NameError
56
+ raise("Cannot evaluate given \"#{v}\" as a Range")
57
+ end
58
+ }
59
+ opts.on_tail("-h", "--help", "Show this message."){puts opts.usage; exit}
60
+
61
+ opts.parse!(ARGV)
62
+ stylesheets=['ulmul2xhtml.css'] if stylesheets==[]
63
+
64
+ u=Ulmul.new(contents_range,'ulmul2xhtml')
65
+ u.parse(ARGF)
66
+ puts u.html(stylesheets,javascripts,name,language)
67
+
68
+ # Local variables:
69
+ # compile-command: "ruby -I ../lib ./ulmul2html ulmul2html"
70
+ # End:
@@ -0,0 +1,330 @@
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/Math/DTD/mathml2/xhtml-math11-f.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
5
+ <head>
6
+ <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
7
+ <title>ULMUL (Ultra Lightweight MarkUp Language)</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" />
12
+ </head>
13
+ <body>
14
+ <div class="slide cover">
15
+ <h1 id="LABEL-1">ULMUL (Ultra Lightweight MarkUp Language)</h1>
16
+ <p>
17
+ "ULMUL" is an original Ultra Lightweight MarkUp Language.
18
+ ULMUL texts can be converted into HTML5 with "ulmul2html5" command
19
+ and into XHTML with "ulmul2xhtml" command.
20
+ TeX stile equations are converted into MathML.
21
+ ULMUL is written in Ruby.
22
+ You can also use ulmul.rb as a library.
23
+ </p>
24
+ <p>
25
+ Homepage of ULMUL: <a href="http://ulmul.rubyforge.org/">http://ulmul.rubyforge.org/</a>
26
+ </p>
27
+ <p>
28
+ Download ULMUL from: <a href="http://rubyforge.org/projects/ulmul">http://rubyforge.org/projects/ulmul</a> or <a href="http://rubygems.org/gems/ulmul">http://rubygems.org/gems/ulmul</a>
29
+ </p>
30
+ <br />Contents:
31
+ <ul>
32
+ <li><a href="#LABEL-2">Features</a></li>
33
+ <li><a href="#LABEL-3">Installation of ULMUL</a>
34
+ <ul>
35
+ <li><a href="#LABEL-4">I. Conservative way; use setup.rb</a></li>
36
+ <li><a href="#LABEL-5">II. RubyGems users can take an easy way</a></li>
37
+ </ul></li>
38
+ <li><a href="#LABEL-6">How to write ULMUL texts</a>
39
+ <ul>
40
+ <li><a href="#LABEL-7">lines</a></li>
41
+ <li><a href="#LABEL-15">Other rules</a></li>
42
+ <li><a href="#LABEL-16">Equations</a></li>
43
+ <li><a href="#LABEL-17">Figures</a></li>
44
+ </ul></li>
45
+ <li><a href="#LABEL-18">Usage</a>
46
+ <ul>
47
+ <li><a href="#LABEL-19">Examples</a></li>
48
+ <li><a href="#LABEL-20">Command options</a></li>
49
+ <li><a href="#LABEL-27">ULMUL and Slidy examples</a></li>
50
+ </ul></li>
51
+ <li><a href="#LABEL-28">TODO</a></li>
52
+ <li><a href="#LABEL-29">Subversion repository</a></li>
53
+ <li><a href="#LABEL-30">Copying</a></li>
54
+ <li><a href="#LABEL-31">Author of ULMUL</a></li>
55
+ </ul>
56
+
57
+ </div>
58
+
59
+
60
+ <div class="slide">
61
+ <h2 id="LABEL-2">Features</h2>
62
+
63
+ <ul>
64
+ <li>TeX style equations between two dollar marks ($) and between Eq. and /Eq.
65
+ will be converted into MathML. You can use Firefox version 3.x, IE+MathPlayer,
66
+ etc. to read MathML.</li>
67
+ <li>ulmul2xhtml output is good with the Slidy presentation environment
68
+ <a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> using Firefox+CSS+XHTML+JavaScript.</li>
69
+ <li>Lines starting from "#" are comments.</li>
70
+ <li>You can add your conversion rules to @subs_rules.</li>
71
+ <li>List of contents will be automatically generated.</li>
72
+ <li>"= ABC EFGH" will be the document title and the cover page of Slidy.</li>
73
+ <li>Use utf-8 for ULMUL texts.
74
+ Specify your natural language with a --language option, e.g. --language=en.</li>
75
+ </ul>
76
+ </div>
77
+
78
+
79
+ <div class="slide">
80
+ <h2 id="LABEL-3">Installation of ULMUL</h2>
81
+ <p>
82
+ There are two different ways to install ULMUL.
83
+ </p>
84
+ <h3 id="LABEL-4">I. Conservative way; use setup.rb</h3>
85
+ <p>
86
+ ulmul-X.Y.Z.tgz package can be installed as:
87
+ </p>
88
+ <pre> $ tar zxf ulmul-X.Y.Z.tgz
89
+ $ cd ulmul-X.Y.Z
90
+ $ su
91
+ # ruby setup.rb
92
+ </pre>
93
+ <p>
94
+ Note that the eimxml and mathml libraries are required.
95
+ </p>
96
+ <h3 id="LABEL-5">II. RubyGems users can take an easy way</h3>
97
+ <p>
98
+ There is an easy way, if you are a RubyGems user:
99
+ </p>
100
+ <pre> $ su
101
+ # gem install ulmul
102
+ </pre>
103
+ <p>
104
+ If you do not have the eimxml and mathml libraries, gem will download and install the
105
+ library automatically.
106
+ </p>
107
+ </div>
108
+
109
+
110
+ <div class="slide">
111
+ <h2 id="LABEL-6">How to write ULMUL texts</h2>
112
+ <p>
113
+ The encode of input file must be utf-8.
114
+ </p>
115
+ <h3 id="LABEL-7">lines</h3>
116
+ <h4 id="LABEL-8">empty</h4>
117
+ <p>
118
+ Empty lines divide paragraphs.
119
+ </p>
120
+ <h4 id="LABEL-9">heading</h4>
121
+ <p>
122
+ Starting with "= ", "== ", "=== ", "==== ", "===== ", and "====== ".
123
+ "= " will be used for the title.
124
+ </p>
125
+ <h4 id="LABEL-10">asterisk</h4>
126
+ <p>
127
+ Lines starting with
128
+ </p>
129
+ <pre>" *"
130
+ " *"
131
+ " *"
132
+ " *"
133
+ " *"
134
+ </pre>
135
+ <p>
136
+ become itemize.
137
+ </p>
138
+ <h4 id="LABEL-11">offset</h4>
139
+ <p>
140
+ Lines starting with some spaces but not asterisks become verbatim lines.
141
+ </p>
142
+ <h4 id="LABEL-12">end</h4>
143
+ <p>
144
+ EOF or "=end" end the process.
145
+ </p>
146
+ <h4 id="LABEL-13">ignore</h4>
147
+ <p>
148
+ Lines starting with"#" and "=begin" are ignored.
149
+ </p>
150
+ <h4 id="LABEL-14">normal</h4>
151
+ <p>
152
+ Other lines.
153
+ </p>
154
+ <h3 id="LABEL-15">Other rules</h3>
155
+
156
+ <ul>
157
+ <li>Lines after "=end" are ignored.</li>
158
+ <li>Add your substitution rules to @subs_rules.</li>
159
+ </ul>
160
+ <h3 id="LABEL-16">Equations</h3>
161
+ <p>
162
+ Input:
163
+ </p>
164
+ <pre>Mass $m$ can be converted into energy $E$ as
165
+ Eq. 1
166
+ E=mc^2.
167
+ /Eq.
168
+ </pre>
169
+ <p>
170
+ Output:
171
+ </p>
172
+ <p>
173
+ 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
174
+ <math xmlns='http://www.w3.org/1998/Math/MathML' display='block'>
175
+ <mi>E</mi>
176
+ <mo>=</mo>
177
+ <mi>m</mi>
178
+ <msup>
179
+ <mi>c</mi>
180
+ <mn>2</mn>
181
+ </msup>
182
+ <mo>.</mo>
183
+ </math>
184
+ </p>
185
+ <p>
186
+ To view the equations in MathML correctly, please use
187
+ </p>
188
+
189
+ <ul>
190
+ <li>Firefox <a href="http://mozilla.jp/firefox/">http://mozilla.jp/firefox/</a></li>
191
+ <li>IE8 + MathPlayer <a href="http://www.dessci.com/en/products/mathplayer/">http://www.dessci.com/en/products/mathplayer/</a></li>
192
+ <li>etc.</li>
193
+ </ul>
194
+ <h3 id="LABEL-17">Figures</h3>
195
+ <p>
196
+ Input:
197
+ </p>
198
+ <pre>Fig. 1 ruby.jpg
199
+ The is a dummy figure for an example.
200
+ Cute red logo of Ruby, isn't it?
201
+ /Fig.
202
+ </pre>
203
+ <p>
204
+ Output:
205
+ </p>
206
+ <div class="figure">
207
+ <img src="ruby.jpg" alt="ruby.jpg" />
208
+ <div class="figcaption">
209
+ The is a dummy figure for an example.
210
+ Cute red logo of Ruby, isn't it?
211
+ </div>
212
+ </div>
213
+ </div>
214
+
215
+
216
+ <div class="slide">
217
+ <h2 id="LABEL-18">Usage</h2>
218
+ <p>
219
+ There are ulmul2xhtml and ulmul2html5 commands.
220
+ </p>
221
+ <p>
222
+ Use .html extensions even for ulmul2xhtml outputs.
223
+ </p>
224
+ <p>
225
+ To view HTML5 documents,
226
+ change the setting of the "html5.enable" entry to "true" in "about:config".
227
+ See <a href="http://kb.mozillazine.org/About:config">http://kb.mozillazine.org/About:config</a> for details.
228
+ </p>
229
+ <h3 id="LABEL-19">Examples</h3>
230
+ <pre>$ ulmul2xhtml without-equations.txt &gt; without-equations.html # XHTML1.0 Transitional
231
+ $ ulmul2xhtml with-equations.txt &gt; with-equations.html # XHTML1.1 + MathML2.0
232
+ $ ulmul2xhtml -n 'Takeshi Nishimatsu' -s ulmul-slidy.css -j slidy.js presentation.txt &gt; presentation.xhtml
233
+ $ ulmul2html5 with-equations.txt &gt; with-equations.html # HTML5
234
+ </pre>
235
+ <h3 id="LABEL-20">Command options</h3>
236
+ <h4 id="LABEL-21">--help</h4>
237
+ <p>
238
+ Show a help message.
239
+ </p>
240
+ <h4 id="LABEL-22">-s, --style</h4>
241
+ <p>
242
+ Specify stylesheet filename.
243
+ </p>
244
+ <h4 id="LABEL-23">-n, --name</h4>
245
+ <p>
246
+ Specify your name for copyright notices.
247
+ </p>
248
+ <h4 id="LABEL-24">-j, --javascript</h4>
249
+ <p>
250
+ Specify JavaScript filename.
251
+ </p>
252
+ <h4 id="LABEL-25">-l, --language</h4>
253
+ <p>
254
+ Specify natural language. Its default is "en".
255
+ </p>
256
+ <h4 id="LABEL-26">-c, --contents-range</h4>
257
+ <p>
258
+ Range of "Contents". Its default is "2..3".
259
+ If you do not need "Contents" at the beginning of the
260
+ output HTML file, set it 3..2.
261
+ </p>
262
+ <h3 id="LABEL-27">ULMUL and Slidy examples</h3>
263
+
264
+ <ul>
265
+ <li><a href="http://loto.sourceforge.net/feram/">http://loto.sourceforge.net/feram/</a>
266
+ <ul>
267
+ <li>Its source is <a href="http://loto.sourceforge.net/feram/README">http://loto.sourceforge.net/feram/README</a></li>
268
+ </ul></li>
269
+ <li><a href="http://loto.sourceforge.net/feram/doc/film.xhtml">http://loto.sourceforge.net/feram/doc/film.xhtml</a>
270
+ <ul>
271
+ <li>It is a Slidy presentation made from <a href="http://loto.sourceforge.net/feram/doc/film.txt">http://loto.sourceforge.net/feram/doc/film.txt</a></li>
272
+ </ul></li>
273
+ </ul>
274
+ </div>
275
+
276
+
277
+ <div class="slide">
278
+ <h2 id="LABEL-28">TODO</h2>
279
+
280
+ <ul>
281
+ <li>rescue syntax errors (raises) in an input file and report the
282
+ errors as #{$FILENAME}:#{file.lineno}:...</li>
283
+ <li>Unit test, tests/ulmul_test.rb</li>
284
+ <li>@body must be XML object, not a String.</li>
285
+ <li>Tables.</li>
286
+ <li>References to figures, tables and code.</li>
287
+ <li>Citation.</li>
288
+ <li>Include highlighted code between Code.../Code.</li>
289
+ </ul>
290
+ </div>
291
+
292
+
293
+ <div class="slide">
294
+ <h2 id="LABEL-29">Subversion repository</h2>
295
+ <p>
296
+ You can checkout the latest source tree of ULMUL anonymously from RubyForge with svn(1) command:
297
+ </p>
298
+ <pre>$ svn co svn://rubyforge.org/var/svn/ulmul/ulmul/trunk ulmul
299
+ </pre>
300
+ </div>
301
+
302
+
303
+ <div class="slide">
304
+ <h2 id="LABEL-30">Copying</h2>
305
+ <p>
306
+ ulmul.rb is distributed in the hope that
307
+ it will be useful, but WITHOUT ANY WARRANTY.
308
+ You can copy, modify and redistribute ulmul.rb,
309
+ but only under the conditions described in
310
+ the GNU General Public License (the "GPL").
311
+ </p>
312
+ <p>
313
+ W3C has copyrights for slidy.js and ulmul-slidy.css (originally
314
+ named slidy.css). Takeshi Nishimatsu modified them.
315
+ You can download the original package, slidy.zip, from
316
+ <a href="http://www.w3.org/Talks/Tools/Slidy/">http://www.w3.org/Talks/Tools/Slidy/</a> . You can find
317
+ their licenses at <a href="http://www.w3.org/Consortium/Legal/copyright-documents">http://www.w3.org/Consortium/Legal/copyright-documents</a>
318
+ and <a href="http://www.w3.org/Consortium/Legal/copyright-software">http://www.w3.org/Consortium/Legal/copyright-software</a> .
319
+ </p>
320
+ </div>
321
+
322
+
323
+ <div class="slide">
324
+ <h2 id="LABEL-31">Author of ULMUL</h2>
325
+ <p>
326
+ Takeshi Nishimatsu (t_nissie{at}yahoo.co.jp)
327
+ </p>
328
+ </div>
329
+ </body>
330
+ </html>