rpeg-markdown 0.2.0 → 1.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.
- data/README.markdown +49 -0
- data/Rakefile +16 -12
- data/ext/extconf.rb +2 -4
- data/ext/markdown.c +9 -17
- data/ext/markdown_lib.h +4 -2
- data/ext/markdown_parser.c +1431 -1344
- data/lib/markdown.rb +1 -41
- data/lib/peg_markdown.rb +59 -0
- data/test/markdown_test.rb +2 -0
- metadata +6 -6
- data/README +0 -38
data/lib/markdown.rb
CHANGED
@@ -1,41 +1 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
class Markdown
|
4
|
-
|
5
|
-
# Original Markdown formatted text.
|
6
|
-
attr_reader :text
|
7
|
-
|
8
|
-
# Set true to have smarty-like quote translation performed.
|
9
|
-
attr_accessor :smart
|
10
|
-
|
11
|
-
# Set true to have footnotes processed.
|
12
|
-
attr_accessor :notes
|
13
|
-
|
14
|
-
# BlueCloth compatible output filtering.
|
15
|
-
attr_accessor :filter_styles, :filter_html
|
16
|
-
|
17
|
-
# RedCloth compatible line folding -- not used for Markdown but
|
18
|
-
# included for compatibility.
|
19
|
-
attr_accessor :fold_lines
|
20
|
-
|
21
|
-
# Create a new Markdown processor. The +text+ argument
|
22
|
-
# should be a string containing Markdown text. Additional arguments may be
|
23
|
-
# supplied to set various processing options:
|
24
|
-
#
|
25
|
-
# * <tt>:smart</tt> - Enable SmartyPants processing.
|
26
|
-
# * <tt>:notes</tt> - Enable footnotes.
|
27
|
-
# * <tt>:filter_styles</tt> - Do not output <tt><style></tt> tags.
|
28
|
-
# * <tt>:filter_html</tt> - Do not output any raw HTML tags included in
|
29
|
-
# the source text.
|
30
|
-
# * <tt>:fold_lines</tt> - RedCloth compatible line folding (not used).
|
31
|
-
#
|
32
|
-
# NOTE: The <tt>:filter_styles</tt> and <tt>:filter_html</tt> extensions
|
33
|
-
# are not yet implemented.
|
34
|
-
def initialize(text, *extensions)
|
35
|
-
@smart = false
|
36
|
-
@notes = false
|
37
|
-
@text = text
|
38
|
-
extensions.each { |e| send("#{e}=", true) }
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
1
|
+
require 'peg_markdown'
|
data/lib/peg_markdown.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'peg_markdown.so'
|
2
|
+
|
3
|
+
# Front-end to jgm's peg-markdown implementation of Markdown, the humane
|
4
|
+
# text markup language.
|
5
|
+
#
|
6
|
+
# A simple processor:
|
7
|
+
# >>> puts Markdown.new("Hello, World.").to_html
|
8
|
+
# <p>Hello, World.</p>
|
9
|
+
#
|
10
|
+
# With other stuff:
|
11
|
+
# >>> puts Markdown.new("_Hello -- World!_", :smart, :filter_html).to_html
|
12
|
+
# <p><em>Hello World!</em></p>
|
13
|
+
#
|
14
|
+
class PEGMarkdown
|
15
|
+
|
16
|
+
# Original Markdown formatted text.
|
17
|
+
attr_reader :text
|
18
|
+
|
19
|
+
# Set true to have smarty-like quote translation performed.
|
20
|
+
attr_accessor :smart
|
21
|
+
|
22
|
+
# Set true to have footnotes processed.
|
23
|
+
attr_accessor :notes
|
24
|
+
|
25
|
+
# Do not output <style> tags included in the source text.
|
26
|
+
attr_accessor :filter_styles
|
27
|
+
|
28
|
+
# Do not output any raw HTML included in the source text.
|
29
|
+
attr_accessor :filter_html
|
30
|
+
|
31
|
+
# Included for compatibility with RedCloth's interface.
|
32
|
+
attr_accessor :fold_lines
|
33
|
+
|
34
|
+
# Create a new Markdown processor. The +text+ argument is a string
|
35
|
+
# containing Markdown text. Variable other arguments may be supplied to
|
36
|
+
# set various processing options:
|
37
|
+
#
|
38
|
+
# * <tt>:smart</tt> - Enable SmartyPants processing.
|
39
|
+
# * <tt>:notes</tt> - Enable footnotes.
|
40
|
+
# * <tt>:filter_styles</tt> - Do not output <style> tags included in the
|
41
|
+
# source text.
|
42
|
+
# * <tt>:filter_html</tt> - Do not output raw HTML included in the
|
43
|
+
# source text.
|
44
|
+
# * <tt>:fold_lines</tt> - RedCloth compatible line folding (not used).
|
45
|
+
#
|
46
|
+
def initialize(text, *extensions)
|
47
|
+
@text = text
|
48
|
+
@smart = false
|
49
|
+
@notes = false
|
50
|
+
@filter_styles = false
|
51
|
+
@filter_html = false
|
52
|
+
extensions.each { |e| send("#{e}=", true) }
|
53
|
+
end
|
54
|
+
|
55
|
+
alias to_s text
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
Markdown = PEGMarkdown unless defined? Markdown
|
data/test/markdown_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rpeg-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: "1.0"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -20,13 +20,13 @@ executables:
|
|
20
20
|
extensions:
|
21
21
|
- ext/extconf.rb
|
22
22
|
extra_rdoc_files:
|
23
|
-
- README
|
24
23
|
- LICENSE
|
25
24
|
files:
|
26
|
-
- README
|
25
|
+
- README.markdown
|
27
26
|
- LICENSE
|
28
27
|
- Rakefile
|
29
28
|
- lib/markdown.rb
|
29
|
+
- lib/peg_markdown.rb
|
30
30
|
- ext/extconf.rb
|
31
31
|
- test/benchmark.rb
|
32
32
|
- test/markdown_test.rb
|
@@ -148,9 +148,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
requirements: []
|
149
149
|
|
150
150
|
rubyforge_project: wink
|
151
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.2.0
|
152
152
|
signing_key:
|
153
153
|
specification_version: 2
|
154
|
-
summary:
|
154
|
+
summary: Fast Markdown implementation
|
155
155
|
test_files:
|
156
156
|
- test/markdown_test.rb
|
data/README
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
Ruby peg-markdown Extension
|
2
|
-
===========================
|
3
|
-
|
4
|
-
The peg-markdown extension wraps John MacFarlane's C implementation of
|
5
|
-
Markdown (see [peg-markdown][1]) in a Ruby extension.
|
6
|
-
|
7
|
-
[1]: http://github.com/jgm/peg-markdown/
|
8
|
-
"Jon MacFarleane's peg-markdown project"
|
9
|
-
|
10
|
-
Installation/Hacking
|
11
|
-
--------------------
|
12
|
-
|
13
|
-
This library requires a recent version of glib2.
|
14
|
-
|
15
|
-
The rpeg-markdown gem is available from Rubyforge:
|
16
|
-
|
17
|
-
$ sudo gem install rpeg-markdown
|
18
|
-
|
19
|
-
A Git repository is available for hacking:
|
20
|
-
|
21
|
-
$ git clone git://github.com/rtomayko/rpeg-markdown.git
|
22
|
-
$ cd rpeg-markdown
|
23
|
-
$ rake test
|
24
|
-
|
25
|
-
Patches happily accepted via fork or email.
|
26
|
-
|
27
|
-
Changes
|
28
|
-
-------
|
29
|
-
|
30
|
-
0.2.0 / 2008-07-12 - Adds test suite and plugs all memory leaks.
|
31
|
-
0.1.0 / 2008-05-30 - Initial release.
|
32
|
-
|
33
|
-
COPYING
|
34
|
-
-------
|
35
|
-
|
36
|
-
The peg-markdown sources are licensed under the GPL and the Ruby extension
|
37
|
-
sources adopts this license. See the file LICENSE included with this
|
38
|
-
distribution for more information.
|