parkdown-libertree 1.4.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +68 -0
  3. data/README.markdown +86 -0
  4. data/Rakefile +170 -0
  5. data/bin/parkdown +13 -0
  6. data/ext/extconf.h +3 -0
  7. data/ext/extconf.rb +15 -0
  8. data/ext/markdown.c +104 -0
  9. data/ext/markdown_lib.c +186 -0
  10. data/ext/markdown_lib.h +44 -0
  11. data/ext/markdown_output.c +1275 -0
  12. data/ext/markdown_parser.c +7275 -0
  13. data/ext/markdown_peg.h +90 -0
  14. data/ext/parsing_functions.c +128 -0
  15. data/ext/utility_functions.c +217 -0
  16. data/lib/markdown.rb +1 -0
  17. data/lib/peg_markdown.rb +104 -0
  18. data/test/MarkdownTest_1.0/MarkdownTest.pl +157 -0
  19. data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.html +17 -0
  20. data/test/MarkdownTest_1.0/Tests/Amps and angle encoding.text +21 -0
  21. data/test/MarkdownTest_1.0/Tests/Auto links.html +18 -0
  22. data/test/MarkdownTest_1.0/Tests/Auto links.text +13 -0
  23. data/test/MarkdownTest_1.0/Tests/Backslash escapes.html +102 -0
  24. data/test/MarkdownTest_1.0/Tests/Backslash escapes.text +104 -0
  25. data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.html +15 -0
  26. data/test/MarkdownTest_1.0/Tests/Blockquotes with code blocks.text +11 -0
  27. data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
  28. data/test/MarkdownTest_1.0/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
  29. data/test/MarkdownTest_1.0/Tests/Horizontal rules.html +71 -0
  30. data/test/MarkdownTest_1.0/Tests/Horizontal rules.text +67 -0
  31. data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).html +14 -0
  32. data/test/MarkdownTest_1.0/Tests/Inline HTML (Advanced).text +14 -0
  33. data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).html +72 -0
  34. data/test/MarkdownTest_1.0/Tests/Inline HTML (Simple).text +69 -0
  35. data/test/MarkdownTest_1.0/Tests/Inline HTML comments.html +13 -0
  36. data/test/MarkdownTest_1.0/Tests/Inline HTML comments.text +13 -0
  37. data/test/MarkdownTest_1.0/Tests/Links, inline style.html +9 -0
  38. data/test/MarkdownTest_1.0/Tests/Links, inline style.text +9 -0
  39. data/test/MarkdownTest_1.0/Tests/Links, reference style.html +18 -0
  40. data/test/MarkdownTest_1.0/Tests/Links, reference style.text +31 -0
  41. data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.html +3 -0
  42. data/test/MarkdownTest_1.0/Tests/Literal quotes in titles.text +7 -0
  43. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.html +314 -0
  44. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Basics.text +306 -0
  45. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.html +942 -0
  46. data/test/MarkdownTest_1.0/Tests/Markdown Documentation - Syntax.text +888 -0
  47. data/test/MarkdownTest_1.0/Tests/Nested blockquotes.html +9 -0
  48. data/test/MarkdownTest_1.0/Tests/Nested blockquotes.text +5 -0
  49. data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.html +137 -0
  50. data/test/MarkdownTest_1.0/Tests/Ordered and unordered lists.text +122 -0
  51. data/test/MarkdownTest_1.0/Tests/Strong and em together.html +7 -0
  52. data/test/MarkdownTest_1.0/Tests/Strong and em together.text +7 -0
  53. data/test/MarkdownTest_1.0/Tests/Tabs.html +25 -0
  54. data/test/MarkdownTest_1.0/Tests/Tabs.text +21 -0
  55. data/test/MarkdownTest_1.0/Tests/Tidyness.html +8 -0
  56. data/test/MarkdownTest_1.0/Tests/Tidyness.text +5 -0
  57. data/test/MarkdownTest_1.0.3/MarkdownTest.pl +176 -0
  58. data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.html +17 -0
  59. data/test/MarkdownTest_1.0.3/Tests/Amps and angle encoding.text +21 -0
  60. data/test/MarkdownTest_1.0.3/Tests/Auto links.html +18 -0
  61. data/test/MarkdownTest_1.0.3/Tests/Auto links.text +13 -0
  62. data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.html +118 -0
  63. data/test/MarkdownTest_1.0.3/Tests/Backslash escapes.text +120 -0
  64. data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.html +15 -0
  65. data/test/MarkdownTest_1.0.3/Tests/Blockquotes with code blocks.text +11 -0
  66. data/test/MarkdownTest_1.0.3/Tests/Code Blocks.html +18 -0
  67. data/test/MarkdownTest_1.0.3/Tests/Code Blocks.text +14 -0
  68. data/test/MarkdownTest_1.0.3/Tests/Code Spans.html +6 -0
  69. data/test/MarkdownTest_1.0.3/Tests/Code Spans.text +6 -0
  70. data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.html +8 -0
  71. data/test/MarkdownTest_1.0.3/Tests/Hard-wrapped paragraphs with list-like lines.text +8 -0
  72. data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.html +71 -0
  73. data/test/MarkdownTest_1.0.3/Tests/Horizontal rules.text +67 -0
  74. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).html +15 -0
  75. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Advanced).text +15 -0
  76. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).html +72 -0
  77. data/test/MarkdownTest_1.0.3/Tests/Inline HTML (Simple).text +69 -0
  78. data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.html +13 -0
  79. data/test/MarkdownTest_1.0.3/Tests/Inline HTML comments.text +13 -0
  80. data/test/MarkdownTest_1.0.3/Tests/Links, inline style.html +11 -0
  81. data/test/MarkdownTest_1.0.3/Tests/Links, inline style.text +12 -0
  82. data/test/MarkdownTest_1.0.3/Tests/Links, reference style.html +52 -0
  83. data/test/MarkdownTest_1.0.3/Tests/Links, reference style.text +71 -0
  84. data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.html +9 -0
  85. data/test/MarkdownTest_1.0.3/Tests/Links, shortcut references.text +20 -0
  86. data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.html +3 -0
  87. data/test/MarkdownTest_1.0.3/Tests/Literal quotes in titles.text +7 -0
  88. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.html +314 -0
  89. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Basics.text +306 -0
  90. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.html +942 -0
  91. data/test/MarkdownTest_1.0.3/Tests/Markdown Documentation - Syntax.text +888 -0
  92. data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.html +9 -0
  93. data/test/MarkdownTest_1.0.3/Tests/Nested blockquotes.text +5 -0
  94. data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.html +148 -0
  95. data/test/MarkdownTest_1.0.3/Tests/Ordered and unordered lists.text +131 -0
  96. data/test/MarkdownTest_1.0.3/Tests/Strong and em together.html +7 -0
  97. data/test/MarkdownTest_1.0.3/Tests/Strong and em together.text +7 -0
  98. data/test/MarkdownTest_1.0.3/Tests/Tabs.html +25 -0
  99. data/test/MarkdownTest_1.0.3/Tests/Tabs.text +21 -0
  100. data/test/MarkdownTest_1.0.3/Tests/Tidyness.html +8 -0
  101. data/test/MarkdownTest_1.0.3/Tests/Tidyness.text +5 -0
  102. data/test/benchmark.rb +49 -0
  103. data/test/markdown_test.rb +84 -0
  104. metadata +150 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1853f8dcdb0b9552b0a3d12694cc4f22d5da1280
4
+ data.tar.gz: 076809e8ff6f6d12b3a281461e0f3eaeee4a2bbd
5
+ SHA512:
6
+ metadata.gz: dea24d3cb538c123d9ea6a91862c193b930185a2557356892453c6fe24f35920dee6cfe02742360f6d1615e65ad10db4371f33d95f53674949f6ddcb7655b0f7
7
+ data.tar.gz: 3c325befc77d31ab8d1a3c34077fd8519267ac3950de76574e0b1ca5cba4fff62a03a7c834d37ce3e89c0c6a83b32445a7ad3086cb7894ef3429246fa9724289
data/LICENSE ADDED
@@ -0,0 +1,68 @@
1
+ Ruby Markdown Extension, implemented using peg-markdown
2
+ Copyright (c) 2011-2014 Ricardo Wurmus
3
+ Copyright (c) 2008 Ryan Tomayko
4
+ markdown in c, implemented using PEG grammar
5
+ Copyright (c) 2008 John MacFarlane
6
+
7
+ Parkdown is released under the GPL
8
+
9
+ The GPL
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of the GNU General Public License as published by
13
+ the Free Software Foundation; either version 2 of the License, or
14
+ (at your option) any later version.
15
+
16
+ This program is distributed in the hope that it will be useful,
17
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ GNU General Public License for more details.
20
+
21
+ You should have received a copy of the GNU General Public License
22
+ along with this program; if not, write to the Free Software
23
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
+
25
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
26
+
27
+ peg-0.1.4 (included for convenience - http://piumarta.com/software/peg/)
28
+
29
+ Copyright (c) 2007 by Ian Piumarta
30
+ All rights reserved.
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a
33
+ copy of this software and associated documentation files (the 'Software'),
34
+ to deal in the Software without restriction, including without limitation
35
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, provided that the above copyright notice(s) and this
38
+ permission notice appear in all copies of the Software. Acknowledgement
39
+ of the use of this Software in supporting documentation would be
40
+ appreciated but is not required.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS'. USE ENTIRELY AT YOUR OWN RISK.
43
+
44
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
45
+
46
+ my_getopt (included for convenience - http://www.geocities.com/bsittler/)
47
+
48
+ Copyright 1997, 2000, 2001, 2002, 2006, Benjamin Sittler
49
+
50
+ Permission is hereby granted, free of charge, to any person
51
+ obtaining a copy of this software and associated documentation
52
+ files (the "Software"), to deal in the Software without
53
+ restriction, including without limitation the rights to use, copy,
54
+ modify, merge, publish, distribute, sublicense, and/or sell copies
55
+ of the Software, and to permit persons to whom the Software is
56
+ furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be
59
+ included in all copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
62
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
63
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
64
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
65
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
66
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
67
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
68
+ DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,86 @@
1
+ Parkdown --- Ruby Markdown library
2
+ ==================================
3
+
4
+ Parkdown is a Ruby extension library around [my fork][1] of
5
+ [John MacFarlane's fast implementation][2] of Markdown in C. This
6
+ extension library is a fork of Ryan Tomayko's [rpeg-markdown][3]
7
+ library. The main difference between Ryan's library and Parkdown is
8
+ the underlying parser. Ryan's library uses an outdated version of
9
+ John MacFarlane's peg-markdown, while Parkdown uses the parser
10
+ generated from [my heavily extended Markdown grammar][4].
11
+
12
+ [1]: https://github.com/rekado/peg-markdown/
13
+ [2]: https://github.com/jgm/peg-markdown/
14
+ [3]: https://github.com/rtomayko/rpeg-markdown
15
+ [4]: https://github.com/rekado/peg-markdown/blob/master/markdown_parser.leg
16
+
17
+ Synopsis
18
+ --------
19
+
20
+ >> require 'markdown'
21
+ >> puts Markdown.new('Hello, world.').to_html
22
+ <p>Hello, world.</p>
23
+
24
+ >> puts Markdown.new('_Hello World!_', :smart, :filter_html).to_html
25
+ <p><em>Hello World!</em></p>
26
+
27
+ >> puts Markdown.new('_Hello World!_').to_latex
28
+ \emph{Hello World!}
29
+
30
+ >> puts Markdown.new('_Hello World!_').to_groff_mm
31
+ .P
32
+ \fIHello world!\fR
33
+
34
+
35
+ Extensions
36
+ ----------
37
+
38
+ Parkdown comes with the following non-standard extensions that are not
39
+ found in the libraries its originally based on:
40
+
41
+ - HTML5 video embedding: `%[caption](file-url.ogv alternative.mp4)`
42
+ - HTML5 audio embedding: `~[title](file-url.ogg alternative.mp3)`
43
+ - autolink: turns plain URLs (not wrapped in angled brackets) into
44
+ clickable links
45
+ - strike-through: `I owe you ~~ten~~ twenty coins.`
46
+ - image filtering: renders images as regular links
47
+ - hard wrap: translate simple line breaks into HTML line breaks
48
+ - code blocks: wrap a block in `~~~` to render it as a code block
49
+ - hashtags: wraps any term starting with `#` in `<span rel="hashtag">...</span>`
50
+ - usernames: wraps any name starting with `@` in `<span rel="username">...</span>`
51
+ - spoilers: a block prefixed with `?>` will be wrapped in a `<div class="spoilers">`.
52
+ Use CSS and JS to hide and show the block as needed.
53
+
54
+
55
+ Hacking
56
+ -------
57
+
58
+ The hard work of rendering some plain text syntax to
59
+ HTML/LaTeX/ODF/etc. is done by the parser that is generated from the
60
+ grammar in peg-markdown. To implement custom extensions, fork
61
+ peg-markdown and extend the grammar. Then update the peg-markdown
62
+ submodule in your fork of parkdown and expose the extension in the
63
+ Ruby library. Use the rake task `rake gather` to build the parser
64
+ from the grammar in the `peg-markdown/` directory and collect the
65
+ files in `ext/`. Then build the extension with `rake build`.
66
+
67
+ Patches are happily accepted via pull requests or email.
68
+
69
+
70
+ Installation
71
+ ------------
72
+
73
+ This library requires a recent version of glib2. All modern GNU
74
+ userland systems should be fine.
75
+
76
+ Install from GEM:
77
+
78
+ $ sudo gem install parkdown
79
+
80
+
81
+ COPYING
82
+ -------
83
+
84
+ The peg-markdown sources are licensed under the GPL and Parkdown
85
+ adopts this license (just as the original rpeg-markdown did). See the
86
+ file LICENSE included with this distribution for more information.
data/Rakefile ADDED
@@ -0,0 +1,170 @@
1
+ require 'rake/clean'
2
+ require 'rake/packagetask'
3
+ require 'rubygems/package_task'
4
+
5
+ task :default => :test
6
+
7
+ DLEXT = RbConfig::CONFIG['DLEXT']
8
+ VERS = '1.4.26'
9
+
10
+ spec =
11
+ Gem::Specification.new do |s|
12
+ s.name = "parkdown"
13
+ s.version = VERS
14
+ s.summary = "Fast Markdown implementation"
15
+ s.files = FileList[
16
+ 'README.markdown','LICENSE','Rakefile',
17
+ '{lib,ext,test}/**.rb','ext/*.{c,h}',
18
+ 'test/MarkdownTest*/**/*',
19
+ 'bin/parkdown'
20
+ ]
21
+ s.bindir = 'bin'
22
+ s.executables << 'parkdown'
23
+ s.require_path = 'lib'
24
+ s.has_rdoc = true
25
+ s.extra_rdoc_files = ['LICENSE']
26
+ s.test_files = FileList['test/markdown_test.rb']
27
+ s.extensions = ['ext/extconf.rb']
28
+
29
+ s.author = 'rekado'
30
+ s.email = 'spam@elephly.net'
31
+ s.homepage = 'http://github.com/rekado/parkdown'
32
+ s.rubyforge_project = 'wink'
33
+ end
34
+
35
+ Gem::PackageTask.new(spec) do |p|
36
+ p.gem_spec = spec
37
+ p.need_tar_gz = true
38
+ p.need_tar = false
39
+ p.need_zip = false
40
+ end
41
+
42
+ namespace :submodule do
43
+ desc 'Init the peg-markdown submodule'
44
+ task :init do |t|
45
+ unless File.exist? 'peg-markdown/markdown.c'
46
+ rm_rf 'peg-markdown'
47
+ sh 'git submodule init peg-markdown'
48
+ sh 'git submodule update peg-markdown'
49
+ end
50
+ end
51
+
52
+ desc 'Update the peg-markdown submodule'
53
+ task :update => :init do
54
+ sh 'git submodule update peg-markdown' unless File.symlink?('peg-markdown')
55
+ end
56
+
57
+ file 'peg-markdown/markdown.c' do
58
+ Rake::Task['submodule:init'].invoke
59
+ end
60
+ task :exist => 'peg-markdown/markdown.c'
61
+ end
62
+
63
+ desc 'Gather required peg-markdown sources into extension directory'
64
+ task :gather => 'submodule:exist' do |t|
65
+ sh 'cd peg-markdown && make markdown_parser.c'
66
+ files =
67
+ FileList[
68
+ 'peg-markdown/markdown_{peg.h,parser.c,output.c,lib.c,lib.h}',
69
+ 'peg-markdown/{utility,parsing}_functions.c',
70
+ 'peg-markdown/{utility,parsing}_functions.h'
71
+ ]
72
+ cp files, 'ext/',
73
+ :preserve => true,
74
+ :verbose => true
75
+ end
76
+
77
+ file 'ext/Makefile' => FileList['ext/{extconf.rb,*.c,*.h,*.rb}'] do
78
+ chdir('ext') { ruby 'extconf.rb' }
79
+ end
80
+ CLEAN.include 'ext/Makefile'
81
+
82
+ file "ext/peg_markdown.#{DLEXT}" => FileList['ext/Makefile', 'ext/*.{c,h,rb}'] do |f|
83
+ sh 'cd ext && make'
84
+ end
85
+ CLEAN.include 'ext/*.{o,bundle,so}'
86
+
87
+ file "lib/peg_markdown.#{DLEXT}" => "ext/peg_markdown.#{DLEXT}" do |f|
88
+ cp f.prerequisites, "lib/", :preserve => true
89
+ end
90
+ CLEAN.include "lib/*.{so,bundle}"
91
+
92
+ desc 'Build the peg_markdown extension'
93
+ task :build => "lib/peg_markdown.#{DLEXT}"
94
+
95
+ desc 'Run unit and conformance tests'
96
+ task :test => [ 'test:unit', 'test:conformance' ]
97
+
98
+ desc 'Run unit tests'
99
+ task 'test:unit' => [:build] do |t|
100
+ ruby 'test/markdown_test.rb'
101
+ end
102
+
103
+ desc "Run conformance tests (MARKDOWN_TEST_VER=#{ENV['MARKDOWN_TEST_VER'] ||= '1.0.3'})"
104
+ task 'test:conformance' => [:build] do |t|
105
+ script = "#{pwd}/bin/parkdown"
106
+ test_version = ENV['MARKDOWN_TEST_VER']
107
+ chdir("test/MarkdownTest_#{test_version}") do
108
+ sh "./MarkdownTest.pl --script='#{script}' --tidy"
109
+ end
110
+ end
111
+
112
+ desc 'Run version 1.0 conformance suite'
113
+ task 'test:conformance:1.0' => [:build] do
114
+ ENV['MARKDOWN_TEST_VER'] = '1.0'
115
+ Rake::Task['test:conformance'].invoke
116
+ end
117
+
118
+ desc 'Run 1.0.3 conformance suite'
119
+ task 'test:conformance:1.0.3' => [:build] do |t|
120
+ ENV['MARKDOWN_TEST_VER'] = '1.0.3'
121
+ Rake::Task['test:conformance'].invoke
122
+ end
123
+
124
+ desc 'Run unit and conformance tests'
125
+ task :test => %w[test:unit test:conformance]
126
+
127
+ desc 'Run benchmarks'
128
+ task :benchmark => :build do |t|
129
+ $:.unshift 'lib'
130
+ load 'test/benchmark.rb'
131
+ end
132
+
133
+ desc "See how much memory we're losing"
134
+ task 'test:mem' => %w[submodule:exist build] do |t|
135
+ $: << File.join(File.dirname(__FILE__), "lib")
136
+ require 'markdown'
137
+ FileList['test/mem.txt', 'peg-markdown/MarkdownTest_1.0.3/Tests/*.text'].each do |file|
138
+ printf "%s: \n", file
139
+ markdown = Markdown.new(File.read(file))
140
+ iterations = (ENV['N'] || 100).to_i
141
+ total, growth = [], []
142
+ iterations.times do |i|
143
+ start = Time.now
144
+ GC.start
145
+ markdown.to_html
146
+ duration = Time.now - start
147
+ GC.start
148
+ total << `ps -o rss= -p #{Process.pid}`.to_i
149
+ next if i == 0
150
+ growth << (total.last - (total[-2] || 0))
151
+ # puts "%03d: %06.02f ms / %dK used / %dK growth" % [ i, duration, total.last, growth.last ]
152
+ end
153
+ average = growth.inject(0) { |sum,x| sum + x } / growth.length
154
+ printf " %dK avg growth (per run) / %dK used (after %d runs)\n", average, total.last, iterations
155
+ end
156
+ end
157
+
158
+ # ==========================================================
159
+ # Rubyforge
160
+ # ==========================================================
161
+
162
+ PKGNAME = "pkg/parkdown-#{VERS}"
163
+
164
+ desc 'Publish new release to rubyforge'
165
+ task :release => [ "#{PKGNAME}.gem", "#{PKGNAME}.tar.gz" ] do |t|
166
+ sh <<-end
167
+ rubyforge add_release wink parkdown #{VERS} #{PKGNAME}.gem &&
168
+ rubyforge add_file wink parkdown #{VERS} #{PKGNAME}.tar.gz
169
+ end
170
+ end
data/bin/parkdown ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'markdown'
5
+ rescue LoadError => boom
6
+ local_path = File.expand_path(File.dirname(__FILE__))
7
+ $: << "#{local_path}/../lib"
8
+ require 'markdown'
9
+ end
10
+
11
+ STDIN.reopen(ARGV[0], 'rb') if ARGV.any?
12
+ markdown = Markdown.new(STDIN.read)
13
+ STDOUT.write(markdown.to_html)
data/ext/extconf.h ADDED
@@ -0,0 +1,3 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #endif
data/ext/extconf.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'mkmf'
2
+
3
+ dir_config('peg_markdown')
4
+
5
+ $objs = %w[markdown.o markdown_lib.o markdown_output.o markdown_parser.o parsing_functions.o utility_functions.o]
6
+
7
+ if pkg_config = find_executable('pkg-config')
8
+ $CFLAGS = `#{pkg_config} --cflags glib-2.0`
9
+ $LDFLAGS = `#{pkg_config} --libs glib-2.0`
10
+ else
11
+ fail "glib2 not found"
12
+ end
13
+
14
+ create_header
15
+ create_makefile('peg_markdown')
data/ext/markdown.c ADDED
@@ -0,0 +1,104 @@
1
+ #include "ruby.h"
2
+ #include "markdown_lib.h"
3
+
4
+ static VALUE rb_cMarkdown;
5
+
6
+ static VALUE
7
+ rb_markdown_to_html(int argc, VALUE *argv, VALUE self)
8
+ {
9
+ /* grab char pointer to markdown input text */
10
+ VALUE text = rb_funcall(self, rb_intern("text"), 0);
11
+ Check_Type(text, T_STRING);
12
+ char * ptext = StringValuePtr(text);
13
+
14
+ /* flip extension bits */
15
+ int extensions = 0;
16
+ if ( rb_funcall(self, rb_intern("smart"), 0) == Qtrue )
17
+ extensions = extensions | EXT_SMART ;
18
+ if ( rb_funcall(self, rb_intern("notes"), 0) == Qtrue )
19
+ extensions = extensions | EXT_NOTES ;
20
+ if ( rb_funcall(self, rb_intern("filter_html"), 0) == Qtrue )
21
+ extensions = extensions | EXT_FILTER_HTML ;
22
+ if ( rb_funcall(self, rb_intern("filter_styles"), 0) == Qtrue )
23
+ extensions = extensions | EXT_FILTER_STYLES ;
24
+ if ( rb_funcall(self, rb_intern("strike"), 0) == Qtrue )
25
+ extensions = extensions | EXT_STRIKE ;
26
+ if ( rb_funcall(self, rb_intern("autolink"), 0) == Qtrue )
27
+ extensions = extensions | EXT_AUTOLINK ;
28
+ if ( rb_funcall(self, rb_intern("hard_wrap"), 0) == Qtrue )
29
+ extensions = extensions | EXT_HARD_WRAP ;
30
+ if ( rb_funcall(self, rb_intern("no_images"), 0) == Qtrue )
31
+ extensions = extensions | EXT_NO_IMAGES ;
32
+ if ( rb_funcall(self, rb_intern("media"), 0) == Qtrue )
33
+ extensions = extensions | EXT_MEDIA ;
34
+ if ( rb_funcall(self, rb_intern("codeblock"), 0) == Qtrue )
35
+ extensions = extensions | EXT_CODEBLOCK ;
36
+ if ( rb_funcall(self, rb_intern("hashtags"), 0) == Qtrue )
37
+ extensions = extensions | EXT_HASHTAGS ;
38
+ if ( rb_funcall(self, rb_intern("usernames"), 0) == Qtrue )
39
+ extensions = extensions | EXT_USERNAMES ;
40
+ if ( rb_funcall(self, rb_intern("spoilerblock"), 0) == Qtrue )
41
+ extensions = extensions | EXT_SPOILERBLOCK ;
42
+
43
+ char *html = markdown_to_string(ptext, extensions, HTML_FORMAT);
44
+ VALUE result = rb_str_new2(html);
45
+ free(html);
46
+
47
+ return result;
48
+ }
49
+
50
+ static VALUE
51
+ rb_markdown_to_latex(int argc, VALUE *argv, VALUE self)
52
+ {
53
+ /* grab char pointer to markdown input text */
54
+ VALUE text = rb_funcall(self, rb_intern("text"), 0);
55
+ Check_Type(text, T_STRING);
56
+ char * ptext = StringValuePtr(text);
57
+
58
+ /* flip extension bits - note that defaults are different than
59
+ * for HTML */
60
+ int extensions = EXT_SMART | EXT_NOTES | EXT_FILTER_HTML | EXT_FILTER_STYLES;
61
+ if ( rb_funcall(self, rb_intern("smart"), 0) == Qfalse )
62
+ extensions = extensions & ~ EXT_SMART ;
63
+ if ( rb_funcall(self, rb_intern("notes"), 0) == Qfalse )
64
+ extensions = extensions & ~ EXT_NOTES ;
65
+
66
+ char *latex = markdown_to_string(ptext, extensions, LATEX_FORMAT);
67
+ VALUE result = rb_str_new2(latex);
68
+ free(latex);
69
+
70
+ return result;
71
+ }
72
+
73
+ static VALUE
74
+ rb_markdown_to_groff_mm(int argc, VALUE *argv, VALUE self)
75
+ {
76
+ /* grab char pointer to markdown input text */
77
+ VALUE text = rb_funcall(self, rb_intern("text"), 0);
78
+ Check_Type(text, T_STRING);
79
+ char * ptext = StringValuePtr(text);
80
+
81
+ /* flip extension bits - note that defaults are different than
82
+ * for HTML */
83
+ int extensions = EXT_SMART | EXT_NOTES | EXT_FILTER_HTML | EXT_FILTER_STYLES;
84
+ if ( rb_funcall(self, rb_intern("smart"), 0) == Qfalse )
85
+ extensions = extensions & ~ EXT_SMART ;
86
+ if ( rb_funcall(self, rb_intern("notes"), 0) == Qfalse )
87
+ extensions = extensions & ~ EXT_NOTES ;
88
+
89
+ char *groff = markdown_to_string(ptext, extensions, GROFF_MM_FORMAT);
90
+ VALUE result = rb_str_new2(groff);
91
+ free(groff);
92
+
93
+ return result;
94
+ }
95
+
96
+ void Init_peg_markdown()
97
+ {
98
+ rb_cMarkdown = rb_define_class("PEGMarkdown", rb_cObject);
99
+ rb_define_method(rb_cMarkdown, "to_html", rb_markdown_to_html, -1);
100
+ rb_define_method(rb_cMarkdown, "to_latex", rb_markdown_to_latex, -1);
101
+ rb_define_method(rb_cMarkdown, "to_groff_mm", rb_markdown_to_groff_mm, -1);
102
+ }
103
+
104
+ // vim: ts=4 sw=4