rpeg-multimarkdown 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/LICENSE +94 -0
  2. data/README.markdown +58 -0
  3. data/Rakefile +171 -0
  4. data/bin/rpeg-multimarkdown +128 -0
  5. data/ext/extconf.h +3 -0
  6. data/ext/extconf.rb +15 -0
  7. data/ext/markdown.c +88 -0
  8. data/ext/markdown_lib.c +211 -0
  9. data/ext/markdown_lib.h +28 -0
  10. data/ext/markdown_output.c +2704 -0
  11. data/ext/markdown_parser.c +8275 -0
  12. data/ext/markdown_peg.h +142 -0
  13. data/ext/odf.c +179 -0
  14. data/ext/odf.h +3 -0
  15. data/ext/parsing_functions.c +182 -0
  16. data/ext/utility_functions.c +535 -0
  17. data/lib/multimarkdown.rb +1 -0
  18. data/lib/peg_multimarkdown.rb +74 -0
  19. data/test/MultiMarkdownTest/BeamerTests/Beamer-Tables.html +76 -0
  20. data/test/MultiMarkdownTest/BeamerTests/Beamer-Tables.tex +64 -0
  21. data/test/MultiMarkdownTest/BeamerTests/Beamer-Tables.text +38 -0
  22. data/test/MultiMarkdownTest/MarkdownTest.pl +182 -0
  23. data/test/MultiMarkdownTest/MemoirTests/Automatic Labels.html +42 -0
  24. data/test/MultiMarkdownTest/MemoirTests/Automatic Labels.tex +47 -0
  25. data/test/MultiMarkdownTest/MemoirTests/Automatic Labels.text +46 -0
  26. data/test/MultiMarkdownTest/MemoirTests/Base Header Level.html +20 -0
  27. data/test/MultiMarkdownTest/MemoirTests/Base Header Level.tex +19 -0
  28. data/test/MultiMarkdownTest/MemoirTests/Base Header Level.text +16 -0
  29. data/test/MultiMarkdownTest/MemoirTests/BibTeX.html +17 -0
  30. data/test/MultiMarkdownTest/MemoirTests/BibTeX.tex +12 -0
  31. data/test/MultiMarkdownTest/MemoirTests/BibTeX.text +11 -0
  32. data/test/MultiMarkdownTest/MemoirTests/Citations.html +63 -0
  33. data/test/MultiMarkdownTest/MemoirTests/Citations.tex +48 -0
  34. data/test/MultiMarkdownTest/MemoirTests/Citations.text +43 -0
  35. data/test/MultiMarkdownTest/MemoirTests/Definition Lists.html +61 -0
  36. data/test/MultiMarkdownTest/MemoirTests/Definition Lists.tex +63 -0
  37. data/test/MultiMarkdownTest/MemoirTests/Definition Lists.text +40 -0
  38. data/test/MultiMarkdownTest/MemoirTests/Dutch.html +23 -0
  39. data/test/MultiMarkdownTest/MemoirTests/Dutch.tex +18 -0
  40. data/test/MultiMarkdownTest/MemoirTests/Dutch.text +17 -0
  41. data/test/MultiMarkdownTest/MemoirTests/Email.html +48 -0
  42. data/test/MultiMarkdownTest/MemoirTests/Email.tex +61 -0
  43. data/test/MultiMarkdownTest/MemoirTests/Email.text +32 -0
  44. data/test/MultiMarkdownTest/MemoirTests/English.html +23 -0
  45. data/test/MultiMarkdownTest/MemoirTests/English.tex +18 -0
  46. data/test/MultiMarkdownTest/MemoirTests/English.text +17 -0
  47. data/test/MultiMarkdownTest/MemoirTests/Footnotes.html +47 -0
  48. data/test/MultiMarkdownTest/MemoirTests/Footnotes.tex +28 -0
  49. data/test/MultiMarkdownTest/MemoirTests/Footnotes.text +26 -0
  50. data/test/MultiMarkdownTest/MemoirTests/French.html +23 -0
  51. data/test/MultiMarkdownTest/MemoirTests/French.tex +18 -0
  52. data/test/MultiMarkdownTest/MemoirTests/French.text +17 -0
  53. data/test/MultiMarkdownTest/MemoirTests/German.html +23 -0
  54. data/test/MultiMarkdownTest/MemoirTests/German.tex +18 -0
  55. data/test/MultiMarkdownTest/MemoirTests/German.text +17 -0
  56. data/test/MultiMarkdownTest/MemoirTests/GermanGuillemets.html +23 -0
  57. data/test/MultiMarkdownTest/MemoirTests/GermanGuillemets.tex +18 -0
  58. data/test/MultiMarkdownTest/MemoirTests/GermanGuillemets.text +17 -0
  59. data/test/MultiMarkdownTest/MemoirTests/Glossary.html +47 -0
  60. data/test/MultiMarkdownTest/MemoirTests/Glossary.tex +30 -0
  61. data/test/MultiMarkdownTest/MemoirTests/Glossary.text +29 -0
  62. data/test/MultiMarkdownTest/MemoirTests/Line Breaks.html +21 -0
  63. data/test/MultiMarkdownTest/MemoirTests/Line Breaks.tex +16 -0
  64. data/test/MultiMarkdownTest/MemoirTests/Line Breaks.text +16 -0
  65. data/test/MultiMarkdownTest/MemoirTests/Link Attributes.html +40 -0
  66. data/test/MultiMarkdownTest/MemoirTests/Link Attributes.tex +61 -0
  67. data/test/MultiMarkdownTest/MemoirTests/Link Attributes.text +51 -0
  68. data/test/MultiMarkdownTest/MemoirTests/Math.html +22 -0
  69. data/test/MultiMarkdownTest/MemoirTests/Math.tex +16 -0
  70. data/test/MultiMarkdownTest/MemoirTests/Math.text +16 -0
  71. data/test/MultiMarkdownTest/MemoirTests/Memoir Mode.html +24 -0
  72. data/test/MultiMarkdownTest/MemoirTests/Memoir Mode.tex +23 -0
  73. data/test/MultiMarkdownTest/MemoirTests/Memoir Mode.text +20 -0
  74. data/test/MultiMarkdownTest/MemoirTests/MetaData.html +22 -0
  75. data/test/MultiMarkdownTest/MemoirTests/MetaData.tex +14 -0
  76. data/test/MultiMarkdownTest/MemoirTests/MetaData.text +15 -0
  77. data/test/MultiMarkdownTest/MemoirTests/Sanity.html +100 -0
  78. data/test/MultiMarkdownTest/MemoirTests/Sanity.tex +101 -0
  79. data/test/MultiMarkdownTest/MemoirTests/Sanity.text +78 -0
  80. data/test/MultiMarkdownTest/MemoirTests/SmartQuotes.html +26 -0
  81. data/test/MultiMarkdownTest/MemoirTests/SmartQuotes.tex +21 -0
  82. data/test/MultiMarkdownTest/MemoirTests/SmartQuotes.text +19 -0
  83. data/test/MultiMarkdownTest/MemoirTests/Swedish.html +23 -0
  84. data/test/MultiMarkdownTest/MemoirTests/Swedish.tex +18 -0
  85. data/test/MultiMarkdownTest/MemoirTests/Swedish.text +17 -0
  86. data/test/MultiMarkdownTest/MemoirTests/Tables.html +221 -0
  87. data/test/MultiMarkdownTest/MemoirTests/Tables.tex +134 -0
  88. data/test/MultiMarkdownTest/MemoirTests/Tables.text +64 -0
  89. data/test/MultiMarkdownTest/MultiMarkdownTests/Automatic Labels.html +41 -0
  90. data/test/MultiMarkdownTest/MultiMarkdownTests/Automatic Labels.tex +46 -0
  91. data/test/MultiMarkdownTest/MultiMarkdownTests/Automatic Labels.text +45 -0
  92. data/test/MultiMarkdownTest/MultiMarkdownTests/Base Header Level.html +20 -0
  93. data/test/MultiMarkdownTest/MultiMarkdownTests/Base Header Level.tex +19 -0
  94. data/test/MultiMarkdownTest/MultiMarkdownTests/Base Header Level.text +16 -0
  95. data/test/MultiMarkdownTest/MultiMarkdownTests/BibTeX.html +16 -0
  96. data/test/MultiMarkdownTest/MultiMarkdownTests/BibTeX.tex +11 -0
  97. data/test/MultiMarkdownTest/MultiMarkdownTests/BibTex.text +10 -0
  98. data/test/MultiMarkdownTest/MultiMarkdownTests/Citations.html +62 -0
  99. data/test/MultiMarkdownTest/MultiMarkdownTests/Citations.tex +47 -0
  100. data/test/MultiMarkdownTest/MultiMarkdownTests/Citations.text +42 -0
  101. data/test/MultiMarkdownTest/MultiMarkdownTests/Definition Lists.html +60 -0
  102. data/test/MultiMarkdownTest/MultiMarkdownTests/Definition Lists.tex +62 -0
  103. data/test/MultiMarkdownTest/MultiMarkdownTests/Definition Lists.text +39 -0
  104. data/test/MultiMarkdownTest/MultiMarkdownTests/Dutch.html +23 -0
  105. data/test/MultiMarkdownTest/MultiMarkdownTests/Dutch.tex +18 -0
  106. data/test/MultiMarkdownTest/MultiMarkdownTests/Dutch.text +17 -0
  107. data/test/MultiMarkdownTest/MultiMarkdownTests/Email.html +47 -0
  108. data/test/MultiMarkdownTest/MultiMarkdownTests/Email.tex +54 -0
  109. data/test/MultiMarkdownTest/MultiMarkdownTests/Email.text +31 -0
  110. data/test/MultiMarkdownTest/MultiMarkdownTests/English.html +23 -0
  111. data/test/MultiMarkdownTest/MultiMarkdownTests/English.tex +18 -0
  112. data/test/MultiMarkdownTest/MultiMarkdownTests/English.text +17 -0
  113. data/test/MultiMarkdownTest/MultiMarkdownTests/Errors.html +16 -0
  114. data/test/MultiMarkdownTest/MultiMarkdownTests/Errors.tex +11 -0
  115. data/test/MultiMarkdownTest/MultiMarkdownTests/Errors.text +11 -0
  116. data/test/MultiMarkdownTest/MultiMarkdownTests/Footnotes.html +46 -0
  117. data/test/MultiMarkdownTest/MultiMarkdownTests/Footnotes.tex +24 -0
  118. data/test/MultiMarkdownTest/MultiMarkdownTests/Footnotes.text +25 -0
  119. data/test/MultiMarkdownTest/MultiMarkdownTests/French.html +23 -0
  120. data/test/MultiMarkdownTest/MultiMarkdownTests/French.tex +18 -0
  121. data/test/MultiMarkdownTest/MultiMarkdownTests/French.text +17 -0
  122. data/test/MultiMarkdownTest/MultiMarkdownTests/German.html +23 -0
  123. data/test/MultiMarkdownTest/MultiMarkdownTests/German.tex +18 -0
  124. data/test/MultiMarkdownTest/MultiMarkdownTests/German.text +17 -0
  125. data/test/MultiMarkdownTest/MultiMarkdownTests/GermanGuillemets.html +23 -0
  126. data/test/MultiMarkdownTest/MultiMarkdownTests/GermanGuillemets.tex +18 -0
  127. data/test/MultiMarkdownTest/MultiMarkdownTests/GermanGuillemets.text +17 -0
  128. data/test/MultiMarkdownTest/MultiMarkdownTests/Glossary.html +46 -0
  129. data/test/MultiMarkdownTest/MultiMarkdownTests/Glossary.tex +26 -0
  130. data/test/MultiMarkdownTest/MultiMarkdownTests/Glossary.text +28 -0
  131. data/test/MultiMarkdownTest/MultiMarkdownTests/Headers.html +46 -0
  132. data/test/MultiMarkdownTest/MultiMarkdownTests/Headers.tex +52 -0
  133. data/test/MultiMarkdownTest/MultiMarkdownTests/Headers.text +49 -0
  134. data/test/MultiMarkdownTest/MultiMarkdownTests/Line Breaks.html +20 -0
  135. data/test/MultiMarkdownTest/MultiMarkdownTests/Line Breaks.tex +15 -0
  136. data/test/MultiMarkdownTest/MultiMarkdownTests/Line Breaks.text +15 -0
  137. data/test/MultiMarkdownTest/MultiMarkdownTests/Link Attributes.html +54 -0
  138. data/test/MultiMarkdownTest/MultiMarkdownTests/Link Attributes.tex +60 -0
  139. data/test/MultiMarkdownTest/MultiMarkdownTests/Link Attributes.text +50 -0
  140. data/test/MultiMarkdownTest/MultiMarkdownTests/List Parsing.html +20 -0
  141. data/test/MultiMarkdownTest/MultiMarkdownTests/List Parsing.tex +17 -0
  142. data/test/MultiMarkdownTest/MultiMarkdownTests/List Parsing.text +11 -0
  143. data/test/MultiMarkdownTest/MultiMarkdownTests/MarkdownInHTML.html +19 -0
  144. data/test/MultiMarkdownTest/MultiMarkdownTests/MarkdownInHTML.tex +13 -0
  145. data/test/MultiMarkdownTest/MultiMarkdownTests/MarkdownInHTML.text +19 -0
  146. data/test/MultiMarkdownTest/MultiMarkdownTests/Math.html +21 -0
  147. data/test/MultiMarkdownTest/MultiMarkdownTests/Math.tex +15 -0
  148. data/test/MultiMarkdownTest/MultiMarkdownTests/Math.text +15 -0
  149. data/test/MultiMarkdownTest/MultiMarkdownTests/MetaData.html +21 -0
  150. data/test/MultiMarkdownTest/MultiMarkdownTests/MetaData.tex +13 -0
  151. data/test/MultiMarkdownTest/MultiMarkdownTests/MetaData.text +14 -0
  152. data/test/MultiMarkdownTest/MultiMarkdownTests/Sanity.html +104 -0
  153. data/test/MultiMarkdownTest/MultiMarkdownTests/Sanity.tex +100 -0
  154. data/test/MultiMarkdownTest/MultiMarkdownTests/Sanity.text +77 -0
  155. data/test/MultiMarkdownTest/MultiMarkdownTests/SmartQuotes.html +29 -0
  156. data/test/MultiMarkdownTest/MultiMarkdownTests/SmartQuotes.tex +24 -0
  157. data/test/MultiMarkdownTest/MultiMarkdownTests/SmartQuotes.text +22 -0
  158. data/test/MultiMarkdownTest/MultiMarkdownTests/Swedish.html +23 -0
  159. data/test/MultiMarkdownTest/MultiMarkdownTests/Swedish.tex +18 -0
  160. data/test/MultiMarkdownTest/MultiMarkdownTests/Swedish.text +17 -0
  161. data/test/MultiMarkdownTest/MultiMarkdownTests/Tables.html +230 -0
  162. data/test/MultiMarkdownTest/MultiMarkdownTests/Tables.tex +133 -0
  163. data/test/MultiMarkdownTest/MultiMarkdownTests/Tables.text +63 -0
  164. data/test/MultiMarkdownTest/MultiMarkdownTests/bibtex.bib +119 -0
  165. data/test/MultiMarkdownTest/README.md +58 -0
  166. data/test/MultiMarkdownTest/Tests/Amps and angle encoding.html +17 -0
  167. data/test/MultiMarkdownTest/Tests/Amps and angle encoding.text +21 -0
  168. data/test/MultiMarkdownTest/Tests/Auto links.html +18 -0
  169. data/test/MultiMarkdownTest/Tests/Auto links.text +13 -0
  170. data/test/MultiMarkdownTest/Tests/Backslash escapes.html +118 -0
  171. data/test/MultiMarkdownTest/Tests/Backslash escapes.text +120 -0
  172. data/test/MultiMarkdownTest/Tests/Blockquotes with code blocks.html +15 -0
  173. data/test/MultiMarkdownTest/Tests/Blockquotes with code blocks.text +11 -0
  174. data/test/MultiMarkdownTest/Tests/Code Blocks.html +18 -0
  175. data/test/MultiMarkdownTest/Tests/Code Blocks.text +14 -0
  176. data/test/MultiMarkdownTest/Tests/Code Spans.html +6 -0
  177. data/test/MultiMarkdownTest/Tests/Code Spans.text +6 -0
  178. data/test/MultiMarkdownTest/Tests/Compatibility.html +5 -0
  179. data/test/MultiMarkdownTest/Tests/Compatibility.text +9 -0
  180. data/test/MultiMarkdownTest/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
  181. data/test/MultiMarkdownTest/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
  182. data/test/MultiMarkdownTest/Tests/Horizontal rules.html +71 -0
  183. data/test/MultiMarkdownTest/Tests/Horizontal rules.text +67 -0
  184. data/test/MultiMarkdownTest/Tests/Inline HTML (Advanced).html +15 -0
  185. data/test/MultiMarkdownTest/Tests/Inline HTML (Advanced).text +15 -0
  186. data/test/MultiMarkdownTest/Tests/Inline HTML (Simple).html +72 -0
  187. data/test/MultiMarkdownTest/Tests/Inline HTML (Simple).text +69 -0
  188. data/test/MultiMarkdownTest/Tests/Inline HTML comments.html +13 -0
  189. data/test/MultiMarkdownTest/Tests/Inline HTML comments.text +13 -0
  190. data/test/MultiMarkdownTest/Tests/Links, inline style.html +11 -0
  191. data/test/MultiMarkdownTest/Tests/Links, inline style.text +12 -0
  192. data/test/MultiMarkdownTest/Tests/Links, reference style.html +52 -0
  193. data/test/MultiMarkdownTest/Tests/Links, reference style.text +71 -0
  194. data/test/MultiMarkdownTest/Tests/Links, shortcut references.html +9 -0
  195. data/test/MultiMarkdownTest/Tests/Links, shortcut references.text +20 -0
  196. data/test/MultiMarkdownTest/Tests/Literal quotes in titles.html +3 -0
  197. data/test/MultiMarkdownTest/Tests/Literal quotes in titles.text +7 -0
  198. data/test/MultiMarkdownTest/Tests/Markdown Documentation - Basics.html +314 -0
  199. data/test/MultiMarkdownTest/Tests/Markdown Documentation - Basics.text +306 -0
  200. data/test/MultiMarkdownTest/Tests/Markdown Documentation - Syntax.html +942 -0
  201. data/test/MultiMarkdownTest/Tests/Markdown Documentation - Syntax.text +888 -0
  202. data/test/MultiMarkdownTest/Tests/Nested blockquotes.html +9 -0
  203. data/test/MultiMarkdownTest/Tests/Nested blockquotes.text +5 -0
  204. data/test/MultiMarkdownTest/Tests/Ordered and unordered lists.html +148 -0
  205. data/test/MultiMarkdownTest/Tests/Ordered and unordered lists.text +131 -0
  206. data/test/MultiMarkdownTest/Tests/Strong and em together.html +7 -0
  207. data/test/MultiMarkdownTest/Tests/Strong and em together.text +7 -0
  208. data/test/MultiMarkdownTest/Tests/Tabs.html +25 -0
  209. data/test/MultiMarkdownTest/Tests/Tabs.text +21 -0
  210. data/test/MultiMarkdownTest/Tests/Tidyness.html +8 -0
  211. data/test/MultiMarkdownTest/Tests/Tidyness.text +5 -0
  212. data/test/benchmark.rb +49 -0
  213. data/test/multimarkdown_test.rb +89 -0
  214. metadata +280 -0
data/LICENSE ADDED
@@ -0,0 +1,94 @@
1
+ Ruby Markdown Extension, implemented using peg-markdown
2
+ Copyright (c) 2008 Ryan Tomayko
3
+ markdown in c, implemented using PEG grammar
4
+ Copyright (c) 2008 John MacFarlane
5
+ Additional MultiMarkdown files
6
+ Copyright (c) 2005-2011 Fletcher T. Penney
7
+ Micro-optparse (included in bin/rpeg-multimarkdown)
8
+ Copyright (c) 2011 Florian Pilz
9
+
10
+ Both peg-markdown and the rpeg-markdown license are released under both the GPL
11
+ and MIT licenses. You may pick the license that best fits your needs.
12
+
13
+ Micro-optparse is released under the MIT license.
14
+
15
+ The GPL
16
+
17
+ This program is free software; you can redistribute it and/or modify
18
+ it under the terms of the GNU General Public License as published by
19
+ the Free Software Foundation; either version 2 of the License, or
20
+ (at your option) any later version.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program; if not, write to the Free Software
29
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
+
31
+ The MIT License
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining a copy
34
+ of this software and associated documentation files (the "Software"), to deal
35
+ in the Software without restriction, including without limitation the rights
36
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
+ copies of the Software, and to permit persons to whom the Software is
38
+ furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in
41
+ all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
+ THE SOFTWARE.
50
+
51
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
52
+
53
+ peg-0.1.4 (included for convenience - http://piumarta.com/software/peg/)
54
+
55
+ Copyright (c) 2007 by Ian Piumarta
56
+ All rights reserved.
57
+
58
+ Permission is hereby granted, free of charge, to any person obtaining a
59
+ copy of this software and associated documentation files (the 'Software'),
60
+ to deal in the Software without restriction, including without limitation
61
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
62
+ copies of the Software, and to permit persons to whom the Software is
63
+ furnished to do so, provided that the above copyright notice(s) and this
64
+ permission notice appear in all copies of the Software. Acknowledgement
65
+ of the use of this Software in supporting documentation would be
66
+ appreciated but is not required.
67
+
68
+ THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK.
69
+
70
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
71
+
72
+ my_getopt (included for convenience - http://www.geocities.com/bsittler/)
73
+
74
+ Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
75
+
76
+ Permission is hereby granted, free of charge, to any person
77
+ obtaining a copy of this software and associated documentation
78
+ files (the "Software"), to deal in the Software without
79
+ restriction, including without limitation the rights to use, copy,
80
+ modify, merge, publish, distribute, sublicense, and/or sell copies
81
+ of the Software, and to permit persons to whom the Software is
82
+ furnished to do so, subject to the following conditions:
83
+
84
+ The above copyright notice and this permission notice shall be
85
+ included in all copies or substantial portions of the Software.
86
+
87
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
88
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
89
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
90
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
91
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
92
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
93
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
94
+ DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,58 @@
1
+ Ruby PEG MultiMarkdown
2
+ ======================
3
+
4
+ An extension library around [Fletcher Penney's implementation][1]
5
+ of MultiMarkdown in C. This library is based (almost entirely) on
6
+ [rpeg-markdown][2], which is a ruby extension library around
7
+ [John MacFarlane's C implementation of Markdown][3].
8
+
9
+ [1]: http://github.com/fletcher/peg-multimarkdown/
10
+ [2]: http://github.com/rtomayko/rpeg-markdown
11
+ [3]: http://github.com/jgm/peg-markdown/
12
+
13
+ Synopsis
14
+ --------
15
+
16
+ >> require 'multimarkdown'
17
+ >> puts MultiMarkdown.new('Hello, world.').to_html
18
+ <p>Hello, world.</p>
19
+
20
+ >> puts MultiMarkdown.new('_Hello World!_', :smart, :filter_html).to_html
21
+ <p><em>Hello World!</em></p>
22
+
23
+ >> puts MultiMarkdown.new('_Hello World!_').to_latex
24
+ \emph{Hello World!}
25
+
26
+ >> puts MultiMarkdown.new("Title: Some document\n\nSome text in the document").extract_metadata("title")
27
+ Some document
28
+
29
+ >> PEGMultiMarkdown.new('Hello! World!')
30
+
31
+ Installation / Hacking
32
+ ----------------------
33
+
34
+ This library requires a recent version of glib2. All modern GNU userland
35
+ systems should be fine.
36
+
37
+ Install from GEM:
38
+
39
+ $ sudo gem install rpeg-multimarkdown
40
+
41
+ Hacking:
42
+
43
+ $ git clone git://github.com/djungelvral/rpeg-multimarkdown.git
44
+ $ cd rpeg-multimarkdown
45
+ $ rake test
46
+
47
+ Changes
48
+ -------
49
+
50
+ * [Version 0.1.1](http://github.com/djungelvral/rpeg-multimarkdown/tree/v0.1.1)
51
+
52
+ COPYING
53
+ -------
54
+
55
+ The peg-markdown, peg-multimarkdown, and Ruby PEG Markdown extension sources
56
+ are licensed under the GPL and the Ruby PEG MultiMarkdown extension sources
57
+ adopts this license. See the file LICENSE included with this distribution for
58
+ more information.
data/Rakefile ADDED
@@ -0,0 +1,171 @@
1
+ require 'rake/clean'
2
+ # require 'rake/packagetask'
3
+ # require 'rake/gempackagetask'
4
+
5
+ require 'rubygems'
6
+ require 'rubygems/package_task'
7
+
8
+ task :default => :test
9
+
10
+ DLEXT = Config::CONFIG['DLEXT']
11
+ VERS = '0.1.1'
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.name = "rpeg-multimarkdown"
15
+ s.version = VERS
16
+ s.summary = "Fast MultiMarkdown implementation"
17
+ s.description =<<-EOF
18
+ A Ruby extension to process MultiMarkdown-formatted
19
+ text, using Fletcher Penney's C peg-multimarkdown
20
+ implementation.
21
+ EOF
22
+ s.files = FileList[
23
+ 'README.markdown','LICENSE','Rakefile',
24
+ '{lib,ext,test}/**.rb','ext/*.{c,h}',
25
+ 'test/MultiMarkdownTest/**/*',
26
+ 'bin/rpeg-multimarkdown'
27
+ ]
28
+ s.bindir = 'bin'
29
+ s.executables << 'rpeg-multimarkdown'
30
+ s.require_path = 'lib'
31
+ s.extra_rdoc_files = ['LICENSE']
32
+ s.test_files = FileList['test/multimarkdown_test.rb']
33
+ s.extensions = ['ext/extconf.rb']
34
+
35
+ s.authors = ['Oliver Whyte','Ryan Tomayko']
36
+ s.email = ['oawhyte@gmail.com','r@tomayko.com']
37
+ s.homepage = 'http://github.com/djungelvral/rpeg-multimarkdown'
38
+ s.rubyforge_project = 'rpeg-multimarkdown'
39
+ end
40
+
41
+ # For Mac OS X -- prevents prevent additional ._* files being added to tarball
42
+ ENV['COPYFILE_DISABLE'] = 'true'
43
+
44
+ Gem::PackageTask.new(spec) do |pkg|
45
+ pkg.need_tar_gz = true
46
+ pkg.need_tar = false
47
+ pkg.need_zip = false
48
+ end
49
+
50
+ namespace :submodule do
51
+ desc 'Init the peg-multimarkdown submodule'
52
+ task :init do |t|
53
+ unless File.exist? 'peg-multimarkdown/markdown.c'
54
+ rm_rf 'peg-multimarkdown'
55
+ sh 'git submodule init peg-multimarkdown'
56
+ sh 'git submodule update peg-multimarkdown'
57
+ end
58
+ end
59
+
60
+ desc 'Update the peg-multimarkdown submodule'
61
+ task :update => :init do
62
+ sh 'git submodule update peg-multimarkdown' unless File.symlink?('peg-multimarkdown')
63
+ end
64
+
65
+ file 'peg-multimarkdown/markdown.c' do
66
+ Rake::Task['submodule:init'].invoke
67
+ end
68
+ task :exist => 'peg-multimarkdown/markdown.c'
69
+ end
70
+
71
+ desc 'Gather required peg-multimarkdown sources into extension directory'
72
+ task :gather => 'submodule:exist' do |t|
73
+ sh 'cd peg-multimarkdown && make markdown_parser.c'
74
+ files =
75
+ FileList[
76
+ 'peg-multimarkdown/markdown_{peg.h,parser.c,output.c,lib.c,lib.h}',
77
+ 'peg-multimarkdown/{utility,parsing}_functions.c',
78
+ 'peg-multimarkdown/odf.{c,h}'
79
+ ]
80
+ cp files, 'ext/',
81
+ :preserve => true,
82
+ :verbose => true
83
+ end
84
+
85
+ file 'ext/Makefile' => FileList['ext/{extconf.rb,*.c,*.h,*.rb}'] do
86
+ chdir('ext') { ruby 'extconf.rb' }
87
+ end
88
+ CLEAN.include 'ext/Makefile'
89
+
90
+ file "ext/peg_multimarkdown.#{DLEXT}" => FileList['ext/Makefile', 'ext/*.{c,h,rb}'] do |f|
91
+ sh 'cd ext && make'
92
+ end
93
+ CLEAN.include 'ext/*.{o,bundle,so}'
94
+
95
+ file "lib/peg_multimarkdown.#{DLEXT}" => "ext/peg_multimarkdown.#{DLEXT}" do |f|
96
+ cp f.prerequisites, "lib/", :preserve => true
97
+ end
98
+ CLEAN.include "lib/*.{so,bundle}"
99
+
100
+ desc 'Build the peg_multimarkdown extension'
101
+ task :build => "lib/peg_multimarkdown.#{DLEXT}"
102
+
103
+ desc 'Run unit and conformance tests'
104
+ task :test => [ 'test:unit', 'test:conformance' ]
105
+
106
+ desc 'Run unit tests'
107
+ task 'test:unit' => [:build] do |t|
108
+ ruby 'test/multimarkdown_test.rb'
109
+ end
110
+
111
+ desc "Run conformance tests"
112
+ task 'test:conformance' => [:build] do |t|
113
+ script = "#{pwd}/bin/rpeg-multimarkdown"
114
+ chdir("test/MultiMarkdownTest") do
115
+ sh "./MarkdownTest.pl --script='#{script}' --flags='-c' --tidy"
116
+ sh "./MarkdownTest.pl --script='#{script}' --testdir='MultiMarkdownTests'"
117
+ sh "./MarkdownTest.pl --script='#{script}' --testdir='MultiMarkdownTests' --flags='-t latex' --ext='.tex'"
118
+ sh "./MarkdownTest.pl --script='#{script}' --testdir='BeamerTests' --flags='-t latex' --ext='.tex'"
119
+ sh "./MarkdownTest.pl --script='#{script}' --testdir='MemoirTests' --flags='-t latex' --ext='.tex'"
120
+ end
121
+ end
122
+
123
+ desc 'Run conformance suite'
124
+ task 'test:conformance' => [:build] do |t|
125
+ Rake::Task['test:conformance'].invoke
126
+ end
127
+
128
+ desc 'Run unit and conformance tests'
129
+ task :test => %w[test:unit test:conformance]
130
+
131
+ desc 'Run benchmarks'
132
+ task :benchmark => :build do |t|
133
+ $:.unshift 'lib'
134
+ load 'test/benchmark.rb'
135
+ end
136
+
137
+ desc "See how much memory we're losing"
138
+ task 'test:mem' => %w[submodule:exist build] do |t|
139
+ $: << File.join(File.dirname(__FILE__), "lib")
140
+ require 'multimarkdown'
141
+ FileList['test/mem.txt', 'peg-multimarkdown/MarkdownTest/Tests/*.text'].each do |file|
142
+ printf "%s: \n", file
143
+ multimarkdown = MultiMarkdown.new(File.read(file),:compatibility)
144
+ iterations = (ENV['N'] || 100).to_i
145
+ total, growth = [], []
146
+ iterations.times do |i|
147
+ start = Time.now
148
+ GC.start
149
+ multimarkdown.to_html
150
+ duration = Time.now - start
151
+ GC.start
152
+ total << `ps -o rss= -p #{Process.pid}`.to_i
153
+ next if i == 0
154
+ growth << (total.last - (total[-2] || 0))
155
+ # puts "%03d: %06.02f ms / %dK used / %dK growth" % [ i, duration, total.last, growth.last ]
156
+ end
157
+ average = growth.inject(0) { |sum,x| sum + x } / growth.length
158
+ printf " %dK avg growth (per run) / %dK used (after %d runs)\n", average, total.last, iterations
159
+ end
160
+ end
161
+
162
+ # ==========================================================
163
+ # Rubyforge
164
+ # ==========================================================
165
+
166
+ PKGNAME = "pkg/rpeg-multimarkdown-#{VERS}"
167
+
168
+ desc 'Publish new release to rubyforge'
169
+ task :release => [ "#{PKGNAME}.gem", "#{PKGNAME}.tar.gz" ] do |t|
170
+ sh "gem push #{PKGNAME}.gem"
171
+ end
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'multimarkdown'
5
+ rescue LoadError => boom
6
+ local_path = File.expand_path(File.dirname(__FILE__))
7
+ $: << "#{local_path}/../lib"
8
+ require 'multimarkdown'
9
+ end
10
+
11
+ # Option parser -- http://florianpilz.github.com/micro-optparse/
12
+
13
+ require 'ostruct'
14
+ require 'optparse'
15
+
16
+ class Parser
17
+ attr_accessor :banner, :version
18
+ def initialize
19
+ @options = []
20
+ @used_short = []
21
+ yield self if block_given?
22
+ end
23
+
24
+ def option(name, desc, settings = {})
25
+ @options << [name, desc, settings]
26
+ end
27
+
28
+ def short_from(name)
29
+ name.to_s.chars.each do |c|
30
+ next if @used_short.include?(c) || c == "_"
31
+ return c # returns from short_from method
32
+ end
33
+ end
34
+
35
+ def validate(options) # remove this method if you want fewer lines of code and don't need validations
36
+ options.each_pair do |key, value|
37
+ opt = @options.find_all{ |o| o[0] == key }.first
38
+ key = "--" << key.to_s.gsub("_", "-")
39
+ unless opt[2][:value_in_set].nil? || opt[2][:value_in_set].include?(value)
40
+ puts "Parameter for #{key} must be in [" << opt[2][:value_in_set].join(", ") << "]" ; exit(1)
41
+ end
42
+ unless opt[2][:value_matches].nil? || opt[2][:value_matches] =~ value
43
+ puts "Parameter for #{key} must match /" << opt[2][:value_matches].source << "/" ; exit(1)
44
+ end
45
+ unless opt[2][:value_satisfies].nil? || opt[2][:value_satisfies].call(value)
46
+ puts "Parameter for #{key} must satisfy given conditions (see description)" ; exit(1)
47
+ end
48
+ end
49
+ end
50
+
51
+ def process!(arguments = ARGV)
52
+ @result = (@default_values || {}).clone # reset or new
53
+ @optionparser ||= OptionParser.new do |p| # prepare only once
54
+ @options.each do |o|
55
+ @used_short << short = o[2][:short] || short_from(o[0])
56
+ @result[o[0]] = o[2][:default] || false # set default
57
+ klass = o[2][:default].class == Fixnum ? Integer : o[2][:default].class
58
+
59
+ if [TrueClass, FalseClass, NilClass].include?(klass) # boolean switch
60
+ p.on("-" << short, "--[no-]" << o[0].to_s.gsub("_", "-"), o[1]) {|x| @result[o[0]] = x}
61
+ else # argument with parameter
62
+ p.on("-" << short, "--" << o[0].to_s.gsub("_", "-") << " " << o[2][:default].to_s, klass, o[1]) {|x| @result[o[0]] = x}
63
+ end
64
+ end
65
+
66
+ p.banner = @banner unless @banner.nil?
67
+ p.on_tail("-h", "--help", "Show this message") {puts p ; exit}
68
+ short = @used_short.include?("v") ? "-V" : "-v"
69
+ p.on_tail(short, "--version", "Print version") {puts @version ; exit} unless @version.nil?
70
+ @default_values = @result.clone # save default values to reset @result in subsequent calls
71
+ end
72
+
73
+ begin
74
+ @optionparser.parse!(arguments)
75
+ rescue OptionParser::ParseError => e
76
+ puts e.message ; exit(1)
77
+ end
78
+
79
+ validate(@result) if self.respond_to?("validate")
80
+ @result
81
+ end
82
+ end
83
+
84
+ # Parse options
85
+ options = Parser.new do |p|
86
+ p.banner = "Ruby interface to MultiMarkdown"
87
+ p.version = "rpeg-multimarkdown 0.1.0"
88
+ p.option :compatibility, "markdown compatibility mode", :default => false
89
+ p.option :filter_html, "filter out raw HTML (except styles)", :default => false
90
+ p.option :process_html, "process MultiMarkdown inside of raw HTML", :default => false
91
+ p.option :filter_styles, "filter out HTML styles", :default => false
92
+ p.option :smart, "use smart typography extension", :default => true
93
+ p.option :notes, "use notes extension", :default => true
94
+ p.option :output, "send output to FILE (default is stdout)", :default => ""
95
+ p.option :to, "convert to FORMAT (default is html)", :default => "html", :value_in_set => ["html","latex","memoir","beamer","odf","opml"]
96
+ p.option :extract, "extract and display specified metadata", :default => ""
97
+ end.process!
98
+
99
+ # Convert options to MultiMarkdown module's options
100
+ mmopts = []
101
+ mmopts << :filter_html if options[:filter_html]
102
+ mmopts << :filter_styles if options[:filter_styles]
103
+ mmopts << :process_html if options[:process_html]
104
+ mmopts << :smart if options[:smart]
105
+ mmopts << :notes if options[:notes]
106
+ mmopts << :compatibility if options[:compatibility]
107
+
108
+ # ARGV will now only contain input filename, if it contains anything
109
+ STDIN.reopen(ARGV[0], 'rb') if ARGV.any?
110
+ multimarkdown = MultiMarkdown.new(STDIN.read,*mmopts)
111
+ STDOUT.reopen(options[:output], 'w') if options[:output]!=""
112
+
113
+ # Print specified metadata if requested
114
+ if options[:extract]!=""
115
+ puts multimarkdown.extract_metadata(options[:extract])
116
+ exit(0)
117
+ end
118
+
119
+ # Do processing
120
+ case options[:to]
121
+ when "html"
122
+ STDOUT.write(multimarkdown.to_html)
123
+ when "latex"
124
+ STDOUT.write(multimarkdown.to_latex)
125
+ else
126
+ puts "Output other than html & latex not currently supported"
127
+ exit(1)
128
+ end