maruku 0.2.13 → 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.
Files changed (86) hide show
  1. data/bin/maruku +23 -15
  2. data/bin/maruku0.3 +37 -0
  3. data/bin/marutest +277 -0
  4. data/docs/changelog-0.3.html +99 -0
  5. data/docs/changelog-0.3.md +84 -0
  6. data/docs/faq.html +46 -0
  7. data/docs/faq.md +32 -0
  8. data/docs/index.html +629 -64
  9. data/docs/markdown_extra2.html +67 -14
  10. data/docs/markdown_syntax.html +631 -94
  11. data/docs/markdown_syntax_2.html +152 -0
  12. data/docs/maruku.html +629 -64
  13. data/docs/maruku.md +108 -105
  14. data/docs/proposal.html +362 -55
  15. data/docs/proposal.md +133 -169
  16. data/docs/todo.html +30 -0
  17. data/lib/maruku.rb +13 -3
  18. data/lib/maruku/errors_management.rb +75 -0
  19. data/lib/maruku/helpers.rb +164 -0
  20. data/lib/maruku/html_helper.rb +33 -13
  21. data/lib/maruku/parse_block.rb +89 -92
  22. data/lib/maruku/parse_doc.rb +43 -18
  23. data/lib/maruku/parse_span.rb +17 -46
  24. data/lib/maruku/parse_span_better.rb +681 -0
  25. data/lib/maruku/string_utils.rb +17 -10
  26. data/lib/maruku/structures.rb +62 -35
  27. data/lib/maruku/structures_iterators.rb +39 -0
  28. data/lib/maruku/tests/benchmark.rb +12 -4
  29. data/lib/maruku/tests/new_parser.rb +318 -0
  30. data/lib/maruku/to_html.rb +113 -44
  31. data/lib/maruku/to_latex.rb +32 -14
  32. data/lib/maruku/to_markdown.rb +110 -0
  33. data/lib/maruku/toc.rb +35 -1
  34. data/lib/maruku/version.rb +10 -1
  35. data/lib/test.rb +29 -0
  36. data/tests/others/escaping.md +6 -4
  37. data/tests/others/links.md +1 -1
  38. data/tests/others/lists_after_paragraph.md +44 -0
  39. data/tests/unittest/abbreviations.md +71 -0
  40. data/tests/unittest/blank.md +43 -0
  41. data/tests/unittest/blanks_in_code.md +131 -0
  42. data/tests/unittest/code.md +64 -0
  43. data/tests/unittest/code2.md +59 -0
  44. data/tests/unittest/code3.md +121 -0
  45. data/tests/unittest/easy.md +36 -0
  46. data/tests/unittest/email.md +39 -0
  47. data/tests/unittest/encoding/iso-8859-1.md +9 -0
  48. data/tests/unittest/encoding/utf-8.md +38 -0
  49. data/tests/unittest/entities.md +174 -0
  50. data/tests/unittest/escaping.md +97 -0
  51. data/tests/unittest/extra_dl.md +81 -0
  52. data/tests/unittest/extra_header_id.md +96 -0
  53. data/tests/unittest/extra_table1.md +78 -0
  54. data/tests/unittest/footnotes.md +120 -0
  55. data/tests/unittest/headers.md +64 -0
  56. data/tests/unittest/hrule.md +77 -0
  57. data/tests/unittest/images.md +114 -0
  58. data/tests/unittest/inline_html.md +185 -0
  59. data/tests/unittest/links.md +162 -0
  60. data/tests/unittest/list1.md +80 -0
  61. data/tests/unittest/list2.md +75 -0
  62. data/tests/unittest/list3.md +111 -0
  63. data/tests/unittest/list4.md +43 -0
  64. data/tests/unittest/lists.md +262 -0
  65. data/tests/unittest/lists_after_paragraph.md +280 -0
  66. data/tests/unittest/lists_ol.md +323 -0
  67. data/tests/unittest/misc_sw.md +751 -0
  68. data/tests/unittest/notyet/escape.md +46 -0
  69. data/tests/unittest/notyet/header_after_par.md +85 -0
  70. data/tests/unittest/notyet/ticks.md +67 -0
  71. data/tests/unittest/notyet/triggering.md +210 -0
  72. data/tests/unittest/one.md +33 -0
  73. data/tests/unittest/paragraph.md +34 -0
  74. data/tests/unittest/paragraph_rules/dont_merge_ref.md +60 -0
  75. data/tests/unittest/paragraph_rules/tab_is_blank.md +43 -0
  76. data/tests/unittest/paragraphs.md +84 -0
  77. data/tests/unittest/recover/recover_links.md +32 -0
  78. data/tests/unittest/references/long_example.md +87 -0
  79. data/tests/unittest/references/spaces_and_numbers.md +27 -0
  80. data/tests/unittest/syntax_hl.md +99 -0
  81. data/tests/unittest/test.md +36 -0
  82. data/tests/unittest/wrapping.md +88 -0
  83. data/tests/utf8-files/simple.md +1 -0
  84. metadata +139 -86
  85. data/lib/maruku/maruku.rb +0 -50
  86. data/tests/a.md +0 -10
@@ -18,6 +18,40 @@
18
18
 
19
19
  require 'rexml/document'
20
20
 
21
+
22
+ class Maruku
23
+ # an instance of Section (see below)
24
+ attr_accessor :toc
25
+ end
26
+
27
+
28
+
29
+ class MDElement
30
+ # This represents a section in the TOC.
31
+ class Section
32
+ # a Fixnum, is == header_element.meta[:level]
33
+ attr_accessor :section_level
34
+
35
+ # An array of fixnum, like [1,2,5] for Section 1.2.5
36
+ attr_accessor :section_number
37
+
38
+ # reference to header (header has h.meta[:section] to self)
39
+ attr_accessor :header_element
40
+
41
+ # Array of immediate children of this element
42
+ attr_accessor :immediate_children
43
+ # Array of Section inside this section
44
+ attr_accessor :section_children
45
+
46
+
47
+ def initialize
48
+ @immediate_children = []
49
+ @section_children = []
50
+ end
51
+ end
52
+ end
53
+
54
+
21
55
  class MDElement
22
56
  class Section
23
57
  def inspect(indent=1)
@@ -134,7 +168,7 @@ class MDElement
134
168
  s2 = Section.new
135
169
  s2.section_level = level
136
170
  s2.header_element = header
137
- header.meta[:section] = s2
171
+ header.instance_variable_set :@section, s2
138
172
 
139
173
  stack.last.section_children.push s2
140
174
  stack.push s2
@@ -17,7 +17,16 @@
17
17
  # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  class Maruku
20
- Version = '0.2.13'
20
+ Version = '0.3.0'
21
21
 
22
22
  MarukuURL = 'http://maruku.rubyforge.org/'
23
+
24
+ # If true, use also PHP Markdown extra syntax
25
+ #
26
+ # Note: it is not guaranteed that if it's false
27
+ # then no special features will be used.
28
+ def markdown_extra?
29
+ true
30
+ end
31
+
23
32
  end
@@ -0,0 +1,29 @@
1
+
2
+ n=100
3
+ $buffer = "blah "*n+"boh"+"beh"*n
4
+ $index = n*5
5
+
6
+ def fun1(reg)
7
+ r2 = /^.{#{$index}}#{reg}/
8
+ r2.match($buffer)
9
+ end
10
+
11
+ def fun2(reg)
12
+ reg.match($buffer[$index, $buffer.size-$index])
13
+ end
14
+
15
+ r = /\w*/
16
+ a = Time.now
17
+ 1000.times do
18
+ fun1(r)
19
+ end
20
+
21
+ b = Time.now
22
+ 1000.times do
23
+ fun2(r)
24
+ end
25
+
26
+ c = Time.now
27
+
28
+ puts "fun1: #{b-a} sec"
29
+ puts "fun2: #{c-b} sec"
@@ -1,14 +1,16 @@
1
- Hello: ! \! \` \{ \} \[ \] \( \) \# \. \! * \* *
1
+ Hello: ! \! \` \{ \} \[ \] \( \) \# \. \! * \*
2
2
 
3
3
 
4
4
  Ora, *emphasis*, **bold**, * <- due asterischi-> * , un underscore-> _ , _emphasis_,
5
5
  incre*dible*e!
6
6
 
7
7
 
8
- This is `Code with an escape: -> \` <- ` (after)
8
+ This is ``Code with an escape: -> ` <- `` (after)
9
9
 
10
- This is ``Code with a special: -> ` <- ``(after)
10
+ This is ```Code with a special: -> ` <- ```(after)
11
11
 
12
12
  `Start ` of paragraph
13
13
 
14
- End of `paragraph `
14
+ End of `paragraph `
15
+
16
+ Exactly one space: ` ` and also here: `` ``
@@ -9,7 +9,7 @@ Search on [Google] [Google]
9
9
 
10
10
  Search on [Google images][]
11
11
 
12
- Search on [Google images][ GoOgle search ]
12
+ Search on [Google images][ GoOgle_search ]
13
13
 
14
14
  Inline: [Google images](http://google.com)
15
15
 
@@ -0,0 +1,44 @@
1
+ Paragraph, list with no space:
2
+ * ciao
3
+
4
+ Paragraph, list with 1 space:
5
+ * ciao
6
+
7
+ Paragraph, list with 3 space:
8
+ * ciao
9
+
10
+ Paragraph, list with 4 spaces:
11
+ * ciao
12
+
13
+ Paragraph, list with 1 tab:
14
+ * ciao
15
+
16
+ Paragraph (1 space after), list with no space:
17
+ * ciao
18
+
19
+ Paragraph (2 spaces after), list with no space:
20
+ * ciao
21
+
22
+ Paragraph (3 spaces after), list with no space:
23
+ * ciao
24
+
25
+ Paragraph with block quote:
26
+ > Quoted
27
+
28
+ Paragraph with header:
29
+ ### header ###
30
+
31
+ Paragraph with header on two lines:
32
+ header
33
+ ------
34
+
35
+
36
+ Paragraph with html after
37
+ <div></div>
38
+
39
+ Paragraph with html after, indented:
40
+ <em>Emphasis</em>
41
+
42
+ Paragraph with html after, indented: <em>Emphasis</em> *tralla* <em>Emph</em>
43
+
44
+ Paragraph with html after, indented: <em>Emphasis *tralla* Emph</em>
@@ -0,0 +1,71 @@
1
+ Write a comment abouth the test here.
2
+ *** Parameters: ***
3
+ {}
4
+ *** Markdown input: ***
5
+
6
+ The HTML specification is maintained by the W3C.
7
+
8
+ *[HTML]: Hyper Text Markup Language
9
+ *[W3C]: World Wide Web Consortium
10
+
11
+
12
+
13
+ Operation Tigra Genesis is going well.
14
+
15
+ *[Tigra Genesis]:
16
+ *** Output of inspect ***
17
+ md_el(:document,[
18
+ md_par([
19
+ "The ",
20
+ md_el(:abbreviation,["HTML"] , {:title=>"Hyper Text Markup Language"}),
21
+ " specification is maintained by the ",
22
+ md_el(:abbreviation,["W3C"] , {:title=>"World Wide Web Consortium"}),
23
+ "."
24
+ ]),
25
+ md_par([
26
+ "Operation ",
27
+ md_el(:abbreviation,["Tigra Genesis"] ),
28
+ " is going well."
29
+ ])
30
+ ] )
31
+ *** Output of to_html ***
32
+
33
+ <p>The <abbr title='Hyper Text Markup Language'>HTML</abbr> specification is maintained by the <abbr title='World Wide Web Consortium'>W3C</abbr>.</p>
34
+
35
+ <p>Operation <abbr>Tigra Genesis</abbr> is going well.</p>
36
+
37
+ *** Output of to_latex ***
38
+ The HTML specification is maintained by the W3C.
39
+
40
+ Operation Tigra Genesis is going well.
41
+
42
+
43
+ *** Output of to_s ***
44
+ The HTML specification is maintained by the W3C.Operation Tigra Genesis is going well.
45
+ *** Output of to_s ***
46
+ The HTML specification is maintained by the W3C.Operation Tigra Genesis is going well.
47
+ *** EOF ***
48
+
49
+
50
+
51
+ OK!
52
+
53
+
54
+
55
+ *** Output of Markdown.pl ***
56
+ <p>The HTML specification is maintained by the W3C.</p>
57
+
58
+ <p>*[HTML]: Hyper Text Markup Language
59
+ *[W3C]: World Wide Web Consortium</p>
60
+
61
+ <p>Operation Tigra Genesis is going well.</p>
62
+
63
+ <p>*[Tigra Genesis]:</p>
64
+
65
+ *** Output of Markdown.pl (parsed) ***
66
+ <p>The HTML specification is maintained by the W3C.</p
67
+ ><p>*[HTML]: Hyper Text Markup Language
68
+ *[W3C]: World Wide Web Consortium</p
69
+ ><p>Operation Tigra Genesis is going well.</p
70
+ ><p>*[Tigra Genesis]:</p
71
+ >
@@ -0,0 +1,43 @@
1
+ Write a comment abouth the test here.
2
+ *** Parameters: ***
3
+ {}
4
+ *** Markdown input: ***
5
+
6
+ Linea 1
7
+
8
+ Linea 2
9
+ *** Output of inspect ***
10
+ md_el(:document,[md_par(["Linea 1"]), md_par(["Linea 2"])] )
11
+ *** Output of to_html ***
12
+
13
+ <p>Linea 1</p>
14
+
15
+ <p>Linea 2</p>
16
+
17
+ *** Output of to_latex ***
18
+ Linea 1
19
+
20
+ Linea 2
21
+
22
+
23
+ *** Output of to_s ***
24
+ Linea 1Linea 2
25
+ *** Output of to_s ***
26
+ Linea 1Linea 2
27
+ *** EOF ***
28
+
29
+
30
+
31
+ OK!
32
+
33
+
34
+
35
+ *** Output of Markdown.pl ***
36
+ <p>Linea 1</p>
37
+
38
+ <p>Linea 2</p>
39
+
40
+ *** Output of Markdown.pl (parsed) ***
41
+ <p>Linea 1</p
42
+ ><p>Linea 2</p
43
+ >
@@ -0,0 +1,131 @@
1
+ Write a comment abouth the test here.
2
+ *** Parameters: ***
3
+ {}
4
+ *** Markdown input: ***
5
+ This block is composed of three lines:
6
+
7
+ one
8
+
9
+ three
10
+
11
+ This block is composed of 5
12
+
13
+
14
+ one
15
+
16
+
17
+ four
18
+
19
+
20
+ This block is composed of 2
21
+
22
+
23
+ two
24
+
25
+
26
+
27
+ *** Output of inspect ***
28
+ md_el(:document,[
29
+ md_par(["This block is composed of three lines:"]),
30
+ md_el(:code,[] , {:raw_code=>"one\n\nthree\n"}),
31
+ md_par(["This block is composed of 5"]),
32
+ md_el(:code,[] , {:raw_code=>"one\n\n\nfour\n\n"}),
33
+ md_par(["This block is composed of 2"]),
34
+ md_el(:code,[] , {:raw_code=>"two"})
35
+ ] )
36
+ *** Output of to_html ***
37
+
38
+ <p>This block is composed of three lines:</p>
39
+
40
+ <pre><code>one
41
+
42
+ three
43
+ </code></pre>
44
+
45
+ <p>This block is composed of 5</p>
46
+
47
+ <pre><code>one
48
+
49
+
50
+ four
51
+
52
+ </code></pre>
53
+
54
+ <p>This block is composed of 2</p>
55
+
56
+ <pre><code>two</code></pre>
57
+
58
+ *** Output of to_latex ***
59
+ This block is composed of three lines:
60
+
61
+ \begin{verbatim}one
62
+
63
+ three
64
+ \end{verbatim}
65
+ This block is composed of 5
66
+
67
+ \begin{verbatim}one
68
+
69
+
70
+ four
71
+
72
+ \end{verbatim}
73
+ This block is composed of 2
74
+
75
+ \begin{verbatim}two\end{verbatim}
76
+
77
+ *** Output of to_s ***
78
+ This block is composed of three lines:This block is composed of 5This block is composed of 2
79
+ *** Output of to_s ***
80
+ This block is composed of three lines:This block is composed of 5This block is composed of 2
81
+ *** EOF ***
82
+
83
+
84
+
85
+ OK!
86
+
87
+
88
+
89
+ *** Output of Markdown.pl ***
90
+ <p>This block is composed of three lines:</p>
91
+
92
+ <pre><code>one
93
+
94
+ three
95
+ </code></pre>
96
+
97
+ <p>This block is composed of 5</p>
98
+
99
+ <pre><code>one
100
+
101
+
102
+ four
103
+ </code></pre>
104
+
105
+ <p>This block is composed of 2</p>
106
+
107
+ <pre><code>two
108
+ </code></pre>
109
+
110
+ *** Output of Markdown.pl (parsed) ***
111
+ <p>This block is composed of three lines:</p
112
+ ><pre
113
+ ><code>one
114
+
115
+ three
116
+ </code
117
+ ></pre
118
+ ><p>This block is composed of 5</p
119
+ ><pre
120
+ ><code>one
121
+
122
+
123
+ four
124
+ </code
125
+ ></pre
126
+ ><p>This block is composed of 2</p
127
+ ><pre
128
+ ><code>two
129
+ </code
130
+ ></pre
131
+ >
@@ -0,0 +1,64 @@
1
+ Comment
2
+ *** Parameters: ***
3
+ {}
4
+ *** Markdown input: ***
5
+ Here is an example of AppleScript:
6
+
7
+ tell application "Foo"
8
+ beep
9
+ end tell
10
+ tab
11
+
12
+ *** Output of inspect ***
13
+ md_el(:document,[
14
+ md_par(["Here is an example of AppleScript:"]),
15
+ md_el(:code,[] , {:raw_code=>"tell application \"Foo\"\n beep\nend tell\n\ttab"})
16
+ ] )
17
+ *** Output of to_html ***
18
+
19
+ <p>Here is an example of AppleScript:</p>
20
+
21
+ <pre><code>tell application &quot;Foo&quot;
22
+ beep
23
+ end tell
24
+ tab</code></pre>
25
+
26
+ *** Output of to_latex ***
27
+ Here is an example of AppleScript:
28
+
29
+ \begin{verbatim}tell application "Foo"
30
+ beep
31
+ end tell
32
+ tab\end{verbatim}
33
+
34
+ *** Output of to_s ***
35
+ Here is an example of AppleScript:
36
+ *** Output of to_s ***
37
+ Here is an example of AppleScript:
38
+ *** EOF ***
39
+
40
+
41
+
42
+ OK!
43
+
44
+
45
+
46
+ *** Output of Markdown.pl ***
47
+ <p>Here is an example of AppleScript:</p>
48
+
49
+ <pre><code>tell application "Foo"
50
+ beep
51
+ end tell
52
+ tab
53
+ </code></pre>
54
+
55
+ *** Output of Markdown.pl (parsed) ***
56
+ <p>Here is an example of AppleScript:</p
57
+ ><pre
58
+ ><code>tell application "Foo"
59
+ beep
60
+ end tell
61
+ tab
62
+ </code
63
+ ></pre
64
+ >