maruku 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/bin/maruku CHANGED
@@ -124,8 +124,8 @@ inputs.each do |f, input|
124
124
  suffix='.pretty_md'
125
125
  out = doc.to_markdown
126
126
  when :s5
127
- suffix='_s5slides.html'
128
- out = doc.to_s5
127
+ suffix='_s5slides.xhtml'
128
+ out = doc.to_s5({:content_only => false})
129
129
  end
130
130
  $stderr.puts "Rendering in %.2f seconds." % (Time.now-t)
131
131
 
@@ -6,87 +6,73 @@
6
6
  <head><meta content='application/xhtml+xml;charset=utf-8' http-equiv='Content-type' /><title></title><link href='style.css' rel='stylesheet' type='text/css' />
7
7
  </head>
8
8
  <body>
9
- <h4 id='last'>Changes in the development version and <strong>experimental</strong> features</h4>
10
- <!-- This is the [math syntax specification][math]. -->
9
+ <h4 id='last'>Changes in the development version (<strong>not yet released</strong>)</h4>
10
+
11
+ <h4 id='stable'>Changes in 0.5.5</h4>
12
+
11
13
  <ul>
12
14
  <li>
13
- <p><em>Jan. 22</em> With very minimal changes, Maruku now works in JRuby. It is very slow, though.</p>
14
-
15
- <p>Some benchmarks:</p>
15
+ <p>Features:</p>
16
16
 
17
17
  <ul>
18
18
  <li>
19
- <p>G4 1.5GhZ, Ruby 1.8.5:</p>
19
+ <p>Input of HTML numeric entities:</p>
20
20
 
21
- <pre><code>Maruku (to_html): parsing 0.65 sec + rendering 0.40 sec = 1.04 sec
22
- Maruku (to_latex): parsing 0.70 sec + rendering 0.21 sec = 0.91 sec</code></pre>
21
+ <pre><code>Examples of numeric character references include &amp;#169; or &amp;#xA9;
22
+ for the copyright symbol, &amp;#913; or &amp;#x391; for the Greek capital
23
+ letter alpha, and &amp;#1575; or &amp;#x627; for the Arabic letter alef.</code></pre>
24
+
25
+ <blockquote>
26
+ <p>Examples of numeric character references include &#169; or &#169; for the copyright symbol, &#913; or &#913; for the Greek capital letter alpha, and &#1575; or &#1575; for the Arabic letter alef.</p>
27
+ </blockquote>
28
+ </li>
29
+ </ul>
23
30
  </li>
24
31
 
25
32
  <li>
26
- <p>G4 1.5GhZ, JRuby 1.9.2:</p>
33
+ <p>Bug fixes:</p>
27
34
 
28
- <pre><code>Maruku (to_html): parsing 4.77 sec + rendering 2.24 sec = 7.01 sec
29
- Maruku (to_latex): parsing 4.04 sec + rendering 1.12 sec = 5.16 sec</code></pre>
30
- </li>
31
- </ul>
35
+ <ul>
36
+ <li>
37
+ <p>Alt text was ignored for images.</p>
32
38
  </li>
33
39
 
34
40
  <li>
35
- <p><em>Jan. 21</em> Integration of Blahtex. PNG export of formula and alignment works ok in Mozilla, Safari, Camino, Opera. IE7 is acting strangely.</p>
41
+ <p>Fixed minor bug in reading HTML inside paragraph.</p>
36
42
  </li>
37
43
 
38
44
  <li>
39
- <p>Support for LaTeX-style formula input, and export to MathML.</p>
45
+ <p>Changed rules for block-level HTML to make it similar to Markdown.pl. For example:</p>
40
46
 
41
- <p><a href='http://golem.ph.utexas.edu/~distler'>Jacques Distler</a> is integrating Maruku into Instiki (a Ruby On Rails-based wiki software), as to have a Ruby wiki with proper math support. You know, these physicists like all those funny symbols.</p>
47
+ <pre><code>Paragraph
48
+ &lt;div&gt;&lt;/div&gt;</code></pre>
42
49
 
43
- <ul>
44
- <li>
45
- <p>To have the MathML export, it is needed to install one of:</p>
50
+ <p>will be translated to</p>
46
51
 
47
- <ul>
48
- <li><span>RiTeX</span> (<code>gem install ritex</code>)</li>
52
+ <pre><code>&lt;p&gt;Paragraph
53
+ &lt;div&gt;&lt;/div&gt;&lt;/p&gt;</code></pre>
49
54
 
50
- <li><a href='http://golem.ph.utexas.edu/~distler/blog/itex2MML.html'>itex2MML</a> supports much more complex formulas than Ritex.</li>
55
+ <p>while this:</p>
51
56
 
52
- <li>PNG for old browser is not here yet. The plan is to use BlahTeX.</li>
53
- </ul>
54
- </li>
55
- </ul>
56
- </li>
57
+ <pre><code>Paragraph
57
58
 
58
- <li>
59
- <p>Command line options for the <code>maruku</code> command:</p>
59
+ &lt;div&gt;&lt;/div&gt;</code></pre>
60
60
 
61
- <pre><code>Usage: maruku [options] [file1.md [file2.md ...
62
- -v, --[no-]verbose Run verbosely
63
- -u, --[no-]unsafe Use unsafe features
64
- -b Break on error
65
- -m, --math-engine ENGINE Uses ENGINE to render MathML
66
- --pdf Write PDF
67
- --html Write HTML
68
- --tex Write LaTeX
69
- --inspect Shows the parsing result
70
- --version Show version
71
- -h, --help Show this message</code></pre>
72
- </li>
61
+ <p>becomes</p>
73
62
 
74
- <li>
75
- <p>Other things:</p>
63
+ <pre><code>&lt;p&gt;Paragraph&lt;/p&gt;
76
64
 
77
- <ul>
78
- <li>
79
- <p>Created the embryo of an extension system. Please don&#8217;t use it yet, as probably the API is bound to change.</p>
65
+ &lt;div&gt;&lt;/div&gt;</code></pre>
66
+ </li>
67
+ </ul>
80
68
  </li>
81
69
 
82
70
  <li>
83
- <p>There are a couple of hidden, unsafe, features that are not enabled by default.</p>
84
- </li>
85
- </ul>
71
+ <p><strong>Pending bugs</strong>: there are some problems when parsing lists. It is difficult to get it right because the spec is very fuzzy. At the moment, list items cannot be indented by more than 1 space.</p>
86
72
  </li>
87
73
  </ul>
88
74
 
89
- <h4 id='stable'>Changes in 0.5.4</h4>
75
+ <h4 id='changes_in_054'>Changes in 0.5.4</h4>
90
76
 
91
77
  <ul>
92
78
  <li>
@@ -453,4 +439,4 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
453
439
  <p>Support for images in PDF.</p>
454
440
  </li>
455
441
  </ul>
456
- <div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 13:34 on Sunday, February 18th, 2007.</span></div></body></html>
442
+ <div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 18:01 on Wednesday, March 07th, 2007.</span></div></body></html>
@@ -2,65 +2,59 @@ CSS: style.css
2
2
  LaTeX CJK: true
3
3
  HTML use syntax: true
4
4
 
5
- #### Changes in the development version and **experimental** features #### {#last}
6
5
 
7
6
  [Jacques Distler]: http://golem.ph.utexas.edu/~distler
8
7
  [itex2MML]: http://golem.ph.utexas.edu/~distler/blog/itex2MML.html
9
8
  [math]: http://rubyforge.maruku.org/math.html
10
- <!-- This is the [math syntax specification][math]. -->
11
9
 
12
- * *Jan. 22* With very minimal changes, Maruku now works in JRuby.
13
- It is very slow, though.
10
+ #### Changes in the development version (**not yet released**) #### {#last}
14
11
 
15
- Some benchmarks:
12
+ #### Changes in 0.5.5 #### {#stable}
16
13
 
17
- * G4 1.5GhZ, Ruby 1.8.5:
18
-
19
- Maruku (to_html): parsing 0.65 sec + rendering 0.40 sec = 1.04 sec
20
- Maruku (to_latex): parsing 0.70 sec + rendering 0.21 sec = 0.91 sec
21
-
22
- * G4 1.5GhZ, JRuby 1.9.2:
23
-
24
- Maruku (to_html): parsing 4.77 sec + rendering 2.24 sec = 7.01 sec
25
- Maruku (to_latex): parsing 4.04 sec + rendering 1.12 sec = 5.16 sec
26
-
27
- * *Jan. 21* Integration of Blahtex. PNG export of formula and alignment works
28
- ok in Mozilla, Safari, Camino, Opera. IE7 is acting strangely.
14
+ * Features:
29
15
 
30
- * Support for LaTeX-style formula input, and export to MathML.
16
+ * Input of HTML numeric entities:
17
+
18
+ Examples of numeric character references include &#169; or &#xA9;
19
+ for the copyright symbol, &#913; or &#x391; for the Greek capital
20
+ letter alpha, and &#1575; or &#x627; for the Arabic letter alef.
31
21
 
32
- [Jacques Distler] is integrating Maruku into Instiki (a Ruby On Rails-based wiki software), as to have a Ruby wiki with proper math support. You know, these physicists like all those funny symbols.
22
+ > Examples of numeric character references include &#169; or &#xA9;
23
+ > for the copyright symbol, &#913; or &#x391; for the Greek capital
24
+ > letter alpha, and &#1575; or &#x627; for the Arabic letter alef.
33
25
 
34
- * To have the MathML export, it is needed to install one of:
35
-
36
- * [RiTeX] (`gem install ritex`)
37
- * [itex2MML] supports much more complex formulas than Ritex.
38
- * PNG for old browser is not here yet. The plan is to use
39
- BlahTeX.
40
-
41
-
42
- * Command line options for the `maruku` command:
43
-
44
- Usage: maruku [options] [file1.md [file2.md ...
45
- -v, --[no-]verbose Run verbosely
46
- -u, --[no-]unsafe Use unsafe features
47
- -b Break on error
48
- -m, --math-engine ENGINE Uses ENGINE to render MathML
49
- --pdf Write PDF
50
- --html Write HTML
51
- --tex Write LaTeX
52
- --inspect Shows the parsing result
53
- --version Show version
54
- -h, --help Show this message
55
-
56
- * Other things:
26
+ * Bug fixes:
57
27
 
58
- * Created the embryo of an extension system. Please don't use it
59
- yet, as probably the API is bound to change.
28
+ * Alt text was ignored for images.
29
+ * Fixed minor bug in reading HTML inside paragraph.
30
+ * Changed rules for block-level HTML to make it similar to Markdown.pl.
31
+ For example:
32
+
33
+ Paragraph
34
+ <div></div>
35
+
36
+ will be translated to
37
+
38
+ <p>Paragraph
39
+ <div></div></p>
40
+
41
+ while this:
42
+
43
+ Paragraph
44
+
45
+ <div></div>
46
+
47
+ becomes
48
+
49
+ <p>Paragraph</p>
50
+
51
+ <div></div>
60
52
 
61
- * There are a couple of hidden, unsafe, features that are not enabled by default.
53
+ * **Pending bugs**: there are some problems when parsing lists. It is difficult
54
+ to get it right because the spec is very fuzzy. At the moment, list items
55
+ cannot be indented by more than 1 space.
62
56
 
63
- #### Changes in 0.5.4 #### {#stable}
57
+ #### Changes in 0.5.4 ####
64
58
 
65
59
  * Features:
66
60
 
@@ -0,0 +1,36 @@
1
+ ## Option number 1 ##
2
+
3
+ * `[ ]{0,3}\+={2,}` pushes the stack
4
+ * `[ ]{0,3}\-={2,}` pops the stack
5
+
6
+ +================ {#id}
7
+ IAL can be put on the same line of a push
8
+
9
+ +== {#id2}
10
+ Or on the same line of a pop:
11
+ -==
12
+
13
+ -==============
14
+
15
+ ## Option number 2 ##
16
+
17
+ Double braces:
18
+
19
+ {{
20
+
21
+ }}{}
22
+
23
+ I don't like, it gets too messy because there are
24
+ too many braces.
25
+
26
+
27
+
28
+ +================ {#id}
29
+
30
+ nested div:
31
+
32
+ +========================
33
+ inside nested DIV
34
+ -========================
35
+
36
+ -==============
@@ -0,0 +1,51 @@
1
+ * *Jan. 22* With very minimal changes, Maruku now works in JRuby.
2
+ It is very slow, though.
3
+
4
+ Some benchmarks:
5
+
6
+ * G4 1.5GhZ, Ruby 1.8.5:
7
+
8
+ Maruku (to_html): parsing 0.65 sec + rendering 0.40 sec = 1.04 sec
9
+ Maruku (to_latex): parsing 0.70 sec + rendering 0.21 sec = 0.91 sec
10
+
11
+ * G4 1.5GhZ, JRuby 1.9.2:
12
+
13
+ Maruku (to_html): parsing 4.77 sec + rendering 2.24 sec = 7.01 sec
14
+ Maruku (to_latex): parsing 4.04 sec + rendering 1.12 sec = 5.16 sec
15
+
16
+ * *Jan. 21* Integration of Blahtex. PNG export of formula and alignment works
17
+ ok in Mozilla, Safari, Camino, Opera. IE7 is acting strangely.
18
+
19
+ * Support for LaTeX-style formula input, and export to MathML.
20
+
21
+ [Jacques Distler] is integrating Maruku into Instiki (a Ruby On Rails-based wiki software), as to have a Ruby wiki with proper math support. You know, these physicists like all those funny symbols.
22
+
23
+ * To have the MathML export, it is needed to install one of:
24
+
25
+ * [RiTeX] (`gem install ritex`)
26
+ * [itex2MML] supports much more complex formulas than Ritex.
27
+ * PNG for old browser is not here yet. The plan is to use
28
+ BlahTeX.
29
+
30
+
31
+ * Command line options for the `maruku` command:
32
+
33
+ Usage: maruku [options] [file1.md [file2.md ...
34
+ -v, --[no-]verbose Run verbosely
35
+ -u, --[no-]unsafe Use unsafe features
36
+ -b Break on error
37
+ -m, --math-engine ENGINE Uses ENGINE to render MathML
38
+ --pdf Write PDF
39
+ --html Write HTML
40
+ --tex Write LaTeX
41
+ --inspect Shows the parsing result
42
+ --version Show version
43
+ -h, --help Show this message
44
+
45
+ * Other things:
46
+
47
+ * Created the embryo of an extension system. Please don't use it
48
+ yet, as probably the API is bound to change.
49
+
50
+ * There are a couple of hidden, unsafe, features that are not enabled by default.
51
+
@@ -91,9 +91,8 @@ module Helpers
91
91
  raw_html = "<marukuwrap>#{raw_html}</marukuwrap>"
92
92
  e.instance_variable_set :@parsed_html,
93
93
  REXML::Document.new(raw_html)
94
- rescue
94
+ rescue #Exception => ex
95
95
  e.instance_variable_set :@parsed_html, nil
96
-
97
96
  # tell_user "Malformed block of HTML:\n"+
98
97
  # add_tabs(raw_html,1,'|')
99
98
  # " #{raw_html.inspect}\n\n"+ex.inspect
@@ -34,10 +34,14 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
34
34
  EverythingElse = %r{^[^<]+}m
35
35
  CommentStart = %r{^<!--}x
36
36
  CommentEnd = %r{^.*-->}
37
- TO_SANITIZE = ['img','hr']
37
+ TO_SANITIZE = ['img','hr','br']
38
38
 
39
39
  attr_reader :rest
40
40
 
41
+ def my_debug(s)
42
+ # puts "---"*10+"\n"+inspect+"\t>>>\t"s
43
+ end
44
+
41
45
  def initialize
42
46
  @rest = ""
43
47
  @tag_stack = []
@@ -46,7 +50,7 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
46
50
  self.state = :inside_element
47
51
  end
48
52
 
49
- attr_accessor :state # :inside_element, :inside_tag, :inside_comment,
53
+ attr_accessor :state # = :inside_element, :inside_tag, :inside_comment,
50
54
 
51
55
  def eat_this(line)
52
56
  @rest = line + @rest
@@ -70,15 +74,18 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
70
74
  @rest = @m.post_match
71
75
  self.state = :inside_comment
72
76
  elsif @m = Tag.match(@rest) then
77
+ my_debug "#{@state}: Tag: #{@m.to_s.inspect}"
73
78
  things_read += 1
74
79
  handle_tag
75
80
  self.state = :inside_element
76
81
  elsif @m = PartialTag.match(@rest) then
82
+ my_debug "#{@state}: PartialTag: #{@m.to_s.inspect}"
77
83
  @already += @m.pre_match
78
84
  @rest = @m.post_match
79
85
  @partial_tag = @m.to_s
80
86
  self.state = :inside_tag
81
87
  elsif @m = EverythingElse.match(@rest)
88
+ my_debug "#{@state}: Everything: #{@m.to_s.inspect}"
82
89
  @already += @m.pre_match + @m.to_s
83
90
  @rest = @m.post_match
84
91
  self.state = :inside_element
@@ -87,7 +94,9 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
87
94
  end
88
95
  when :inside_tag
89
96
  if @m = /^[^>]*>/.match(@rest) then
97
+ my_debug "#{@state}: inside_tag: matched #{@m.to_s.inspect}"
90
98
  @partial_tag += @m.to_s
99
+ my_debug "#{@state}: inside_tag: matched TOTAL: #{@partial_tag.to_s.inspect}"
91
100
  @rest = @partial_tag + @m.post_match
92
101
  @partial_tag = nil
93
102
  self.state = :inside_element
@@ -112,16 +121,16 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
112
121
 
113
122
  is_closing = !!@m[1]
114
123
  tag = @m[2]
115
- attributes = @m[3]
116
-
124
+ attributes = @m[3].to_s
117
125
 
118
126
  is_single = false
119
- if attributes =~ /\A(.*)\/\Z/
120
- attributes = $1
127
+ if attributes[-1] == ?/ # =~ /\A(.*)\/\Z/
128
+ attributes = attributes[0, attributes.size-1]
121
129
  is_single = true
122
130
  end
123
131
 
124
- # puts "READ TAG #{@m.to_s.inspect} tag = #{tag} closing? #{is_closing} single = #{is_single}"
132
+ my_debug "Attributes: #{attributes.inspect}"
133
+ my_debug "READ TAG #{@m.to_s.inspect} tag = #{tag} closing? #{is_closing} single = #{is_single}"
125
134
 
126
135
  if TO_SANITIZE.include? tag
127
136
  attributes.strip!
@@ -145,7 +154,10 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
145
154
  else
146
155
  @already += @m.to_s
147
156
 
148
- @tag_stack.push(tag) unless is_single
157
+ if not is_single
158
+ @tag_stack.push(tag)
159
+ my_debug "Pushing #{tag.inspect} when read #{@m.to_s.inspect}"
160
+ end
149
161
  end
150
162
  end
151
163
  def error(s)
@@ -167,6 +179,8 @@ module MaRuKu; module In; module Markdown; module SpanLevelParser
167
179
  @already
168
180
  end
169
181
 
182
+ def rest() @rest end
183
+
170
184
  def is_finished?
171
185
  (self.state == :inside_element) and @tag_stack.empty?
172
186
  end
@@ -237,6 +237,10 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
237
237
  ex = e.inspect + e.backtrace.join("\n")
238
238
  maruku_error "Bad block-level HTML:\n#{add_tabs(ex,1,'|')}\n", src
239
239
  end
240
+ if not (h.rest =~ /^\s*$/)
241
+ maruku_error "Could you please format this better?\n"+
242
+ "I see that #{h.rest.inspect} is left after the raw HTML.", src
243
+ end
240
244
  raw_html = h.stuff_you_read
241
245
  return md_html(raw_html)
242
246
  end
@@ -246,7 +250,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
246
250
  while src.cur_line
247
251
  # :olist does not break
248
252
  case t = src.cur_line.md_type
249
- when :quote,:header3,:empty,:raw_html,:ref_definition,:ial,:xml_instr
253
+ when :quote,:header3,:empty,:ref_definition,:ial #,:xml_instr,:raw_html
250
254
  break
251
255
  when :olist,:ulist
252
256
  break if src.next_line.md_type == t
@@ -349,6 +353,7 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
349
353
  # collect all indented lines
350
354
  saw_empty = false; saw_anything_after = false
351
355
  while src.cur_line
356
+ # puts "Reading indent = #{indentation} #{src.cur_line.inspect}"
352
357
  #puts "#{src.cur_line.md_type} #{src.cur_line.inspect}"
353
358
  if src.cur_line.md_type == :empty
354
359
  saw_empty = true
@@ -365,7 +370,9 @@ module MaRuKu; module In; module Markdown; module BlockLevelParser
365
370
  end
366
371
  saw_anything_after = true
367
372
  else
368
- break if break_list.include? src.cur_line.md_type
373
+ # if src.cur_line[0] != ?\
374
+ break if break_list.include? src.cur_line.md_type
375
+ # end
369
376
  # break if src.cur_line.md_type != :text
370
377
  end
371
378