bean-kramdown 0.13.5
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/AUTHORS +1 -0
- data/CONTRIBUTERS +11 -0
- data/COPYING +24 -0
- data/ChangeLog +6683 -0
- data/GPL +674 -0
- data/README +43 -0
- data/VERSION +1 -0
- data/bin/kramdown +78 -0
- data/lib/kramdown.rb +23 -0
- data/lib/kramdown/compatibility.rb +49 -0
- data/lib/kramdown/converter.rb +41 -0
- data/lib/kramdown/converter/base.rb +169 -0
- data/lib/kramdown/converter/bean_html.rb +71 -0
- data/lib/kramdown/converter/html.rb +411 -0
- data/lib/kramdown/converter/kramdown.rb +428 -0
- data/lib/kramdown/converter/latex.rb +607 -0
- data/lib/kramdown/converter/toc.rb +82 -0
- data/lib/kramdown/document.rb +119 -0
- data/lib/kramdown/element.rb +524 -0
- data/lib/kramdown/error.rb +30 -0
- data/lib/kramdown/options.rb +373 -0
- data/lib/kramdown/parser.rb +39 -0
- data/lib/kramdown/parser/base.rb +136 -0
- data/lib/kramdown/parser/bean_kramdown.rb +25 -0
- data/lib/kramdown/parser/bean_kramdown/info_box.rb +52 -0
- data/lib/kramdown/parser/bean_kramdown/oembed.rb +230 -0
- data/lib/kramdown/parser/html.rb +570 -0
- data/lib/kramdown/parser/kramdown.rb +339 -0
- data/lib/kramdown/parser/kramdown/abbreviation.rb +71 -0
- data/lib/kramdown/parser/kramdown/autolink.rb +53 -0
- data/lib/kramdown/parser/kramdown/blank_line.rb +43 -0
- data/lib/kramdown/parser/kramdown/block_boundary.rb +46 -0
- data/lib/kramdown/parser/kramdown/blockquote.rb +51 -0
- data/lib/kramdown/parser/kramdown/codeblock.rb +63 -0
- data/lib/kramdown/parser/kramdown/codespan.rb +56 -0
- data/lib/kramdown/parser/kramdown/emphasis.rb +70 -0
- data/lib/kramdown/parser/kramdown/eob.rb +39 -0
- data/lib/kramdown/parser/kramdown/escaped_chars.rb +38 -0
- data/lib/kramdown/parser/kramdown/extensions.rb +204 -0
- data/lib/kramdown/parser/kramdown/footnote.rb +74 -0
- data/lib/kramdown/parser/kramdown/header.rb +68 -0
- data/lib/kramdown/parser/kramdown/horizontal_rule.rb +39 -0
- data/lib/kramdown/parser/kramdown/html.rb +169 -0
- data/lib/kramdown/parser/kramdown/html_entity.rb +44 -0
- data/lib/kramdown/parser/kramdown/image.rb +157 -0
- data/lib/kramdown/parser/kramdown/line_break.rb +38 -0
- data/lib/kramdown/parser/kramdown/link.rb +154 -0
- data/lib/kramdown/parser/kramdown/list.rb +240 -0
- data/lib/kramdown/parser/kramdown/math.rb +65 -0
- data/lib/kramdown/parser/kramdown/paragraph.rb +63 -0
- data/lib/kramdown/parser/kramdown/smart_quotes.rb +214 -0
- data/lib/kramdown/parser/kramdown/table.rb +178 -0
- data/lib/kramdown/parser/kramdown/typographic_symbol.rb +52 -0
- data/lib/kramdown/parser/markdown.rb +69 -0
- data/lib/kramdown/utils.rb +42 -0
- data/lib/kramdown/utils/entities.rb +348 -0
- data/lib/kramdown/utils/html.rb +85 -0
- data/lib/kramdown/utils/ordered_hash.rb +100 -0
- data/lib/kramdown/version.rb +28 -0
- metadata +140 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown.
|
7
|
+
#
|
8
|
+
# kramdown is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
module Kramdown
|
24
|
+
|
25
|
+
module Utils
|
26
|
+
|
27
|
+
# Provides convenience methods for HTML related tasks.
|
28
|
+
#
|
29
|
+
# *Note* that this module has to be mixed into a class that has a @root (containing an element
|
30
|
+
# of type :root) and an @options (containing an options hash) instance variable so that some of
|
31
|
+
# the methods can work correctly.
|
32
|
+
module Html
|
33
|
+
|
34
|
+
# Convert the entity +e+ to a string. The optional parameter +original+ may contain the
|
35
|
+
# original representation of the entity.
|
36
|
+
#
|
37
|
+
# This method uses the option +entity_output+ to determine the output form for the entity.
|
38
|
+
def entity_to_str(e, original = nil)
|
39
|
+
if RUBY_VERSION >= '1.9' && @options[:entity_output] == :as_char &&
|
40
|
+
(c = e.char.encode(@root.options[:encoding]) rescue nil) && !ESCAPE_MAP.has_key?(c)
|
41
|
+
c
|
42
|
+
elsif (@options[:entity_output] == :as_input || @options[:entity_output] == :as_char) && original
|
43
|
+
original
|
44
|
+
elsif @options[:entity_output] == :numeric || e.name.nil?
|
45
|
+
"&##{e.code_point};"
|
46
|
+
else
|
47
|
+
"&#{e.name};"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Return the HTML representation of the attributes +attr+.
|
52
|
+
def html_attributes(attr)
|
53
|
+
attr.map {|k,v| v.nil? || (k == 'id' && v.strip.empty?) ? '' : " #{k}=\"#{escape_html(v.to_s, :attribute)}\"" }.join('')
|
54
|
+
end
|
55
|
+
|
56
|
+
# :stopdoc:
|
57
|
+
ESCAPE_MAP = {
|
58
|
+
'<' => '<',
|
59
|
+
'>' => '>',
|
60
|
+
'&' => '&',
|
61
|
+
'"' => '"'
|
62
|
+
}
|
63
|
+
ESCAPE_ALL_RE = /<|>|&/
|
64
|
+
ESCAPE_TEXT_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&/)
|
65
|
+
ESCAPE_ATTRIBUTE_RE = Regexp.union(REXML::Parsers::BaseParser::REFERENCE_RE, /<|>|&|"/)
|
66
|
+
ESCAPE_RE_FROM_TYPE = {
|
67
|
+
:all => ESCAPE_ALL_RE,
|
68
|
+
:text => ESCAPE_TEXT_RE,
|
69
|
+
:attribute => ESCAPE_ATTRIBUTE_RE
|
70
|
+
}
|
71
|
+
# :startdoc:
|
72
|
+
|
73
|
+
# Escape the special HTML characters in the string +str+. The parameter +type+ specifies what
|
74
|
+
# is escaped: :all - all special HTML characters as well as entities, :text - all special HTML
|
75
|
+
# characters except the quotation mark but no entities and :attribute - all special HTML
|
76
|
+
# characters including the quotation mark but no entities.
|
77
|
+
def escape_html(str, type = :all)
|
78
|
+
str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m}
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown.
|
7
|
+
#
|
8
|
+
# kramdown is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
module Kramdown
|
24
|
+
|
25
|
+
module Utils
|
26
|
+
|
27
|
+
if RUBY_VERSION < '1.9'
|
28
|
+
|
29
|
+
# A partial hash implementation which preserves the insertion order of the keys.
|
30
|
+
#
|
31
|
+
# *Note* that this class is only used on Ruby 1.8 since the built-in Hash on Ruby 1.9
|
32
|
+
# automatically preserves the insertion order. However, to remain compatibility only the
|
33
|
+
# methods defined in this class may be used when working with OrderedHash on Ruby 1.9.
|
34
|
+
class OrderedHash
|
35
|
+
|
36
|
+
include Enumerable
|
37
|
+
|
38
|
+
# Initialize the OrderedHash object.
|
39
|
+
def initialize
|
40
|
+
@data = {}
|
41
|
+
@order = []
|
42
|
+
end
|
43
|
+
|
44
|
+
# Iterate over the stored keys in insertion order.
|
45
|
+
def each
|
46
|
+
@order.each {|k| yield(k, @data[k])}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return the value for the +key+.
|
50
|
+
def [](key)
|
51
|
+
@data[key]
|
52
|
+
end
|
53
|
+
|
54
|
+
# Return +true+ if the hash contains the key.
|
55
|
+
def has_key?(key)
|
56
|
+
@data.has_key?(key)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Set the value for the +key+ to +val+.
|
60
|
+
def []=(key, val)
|
61
|
+
@order << key if !@data.has_key?(key)
|
62
|
+
@data[key] = val
|
63
|
+
end
|
64
|
+
|
65
|
+
# Delete the +key+.
|
66
|
+
def delete(key)
|
67
|
+
@order.delete(key)
|
68
|
+
@data.delete(key)
|
69
|
+
end
|
70
|
+
|
71
|
+
def merge!(other)
|
72
|
+
other.each {|k,v| self[k] = v}
|
73
|
+
self
|
74
|
+
end
|
75
|
+
|
76
|
+
def dup #:nodoc:
|
77
|
+
new_object = super
|
78
|
+
new_object.instance_variable_set(:@data, @data.dup)
|
79
|
+
new_object.instance_variable_set(:@order, @order.dup)
|
80
|
+
new_object
|
81
|
+
end
|
82
|
+
|
83
|
+
def ==(other) #:nodoc:
|
84
|
+
return false unless other.kind_of?(self.class)
|
85
|
+
@data == other.instance_variable_get(:@data) && @order == other.instance_variable_get(:@order)
|
86
|
+
end
|
87
|
+
|
88
|
+
def inspect #:nodoc:
|
89
|
+
"{" + map {|k,v| "#{k.inspect}=>#{v.inspect}"}.join(" ") + "}"
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
else
|
95
|
+
OrderedHash = Hash
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
#--
|
4
|
+
# Copyright (C) 2009-2012 Thomas Leitner <t_leitner@gmx.at>
|
5
|
+
#
|
6
|
+
# This file is part of kramdown.
|
7
|
+
#
|
8
|
+
# kramdown is free software: you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation, either version 3 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# This program is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
#++
|
21
|
+
#
|
22
|
+
|
23
|
+
module Kramdown
|
24
|
+
|
25
|
+
# The kramdown version.
|
26
|
+
VERSION = '0.13.7'
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bean-kramdown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 33
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 13
|
9
|
+
- 5
|
10
|
+
version: 0.13.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Vincent Siebert
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-05-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: coderay
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 23
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 1.0.0
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
description: bean-kramdown is yet-another-markdown-parser but fast, pure Ruby, using a strict syntax definition and supporting several common extensions.
|
37
|
+
email:
|
38
|
+
- vincent@thebeansgroup.com
|
39
|
+
executables:
|
40
|
+
- kramdown
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- README
|
45
|
+
files:
|
46
|
+
- lib/kramdown/compatibility.rb
|
47
|
+
- lib/kramdown/converter/base.rb
|
48
|
+
- lib/kramdown/converter/bean_html.rb
|
49
|
+
- lib/kramdown/converter/html.rb
|
50
|
+
- lib/kramdown/converter/kramdown.rb
|
51
|
+
- lib/kramdown/converter/latex.rb
|
52
|
+
- lib/kramdown/converter/toc.rb
|
53
|
+
- lib/kramdown/converter.rb
|
54
|
+
- lib/kramdown/document.rb
|
55
|
+
- lib/kramdown/element.rb
|
56
|
+
- lib/kramdown/error.rb
|
57
|
+
- lib/kramdown/options.rb
|
58
|
+
- lib/kramdown/parser/base.rb
|
59
|
+
- lib/kramdown/parser/bean_kramdown/info_box.rb
|
60
|
+
- lib/kramdown/parser/bean_kramdown/oembed.rb
|
61
|
+
- lib/kramdown/parser/bean_kramdown.rb
|
62
|
+
- lib/kramdown/parser/html.rb
|
63
|
+
- lib/kramdown/parser/kramdown/abbreviation.rb
|
64
|
+
- lib/kramdown/parser/kramdown/autolink.rb
|
65
|
+
- lib/kramdown/parser/kramdown/blank_line.rb
|
66
|
+
- lib/kramdown/parser/kramdown/block_boundary.rb
|
67
|
+
- lib/kramdown/parser/kramdown/blockquote.rb
|
68
|
+
- lib/kramdown/parser/kramdown/codeblock.rb
|
69
|
+
- lib/kramdown/parser/kramdown/codespan.rb
|
70
|
+
- lib/kramdown/parser/kramdown/emphasis.rb
|
71
|
+
- lib/kramdown/parser/kramdown/eob.rb
|
72
|
+
- lib/kramdown/parser/kramdown/escaped_chars.rb
|
73
|
+
- lib/kramdown/parser/kramdown/extensions.rb
|
74
|
+
- lib/kramdown/parser/kramdown/footnote.rb
|
75
|
+
- lib/kramdown/parser/kramdown/header.rb
|
76
|
+
- lib/kramdown/parser/kramdown/horizontal_rule.rb
|
77
|
+
- lib/kramdown/parser/kramdown/html.rb
|
78
|
+
- lib/kramdown/parser/kramdown/html_entity.rb
|
79
|
+
- lib/kramdown/parser/kramdown/image.rb
|
80
|
+
- lib/kramdown/parser/kramdown/line_break.rb
|
81
|
+
- lib/kramdown/parser/kramdown/link.rb
|
82
|
+
- lib/kramdown/parser/kramdown/list.rb
|
83
|
+
- lib/kramdown/parser/kramdown/math.rb
|
84
|
+
- lib/kramdown/parser/kramdown/paragraph.rb
|
85
|
+
- lib/kramdown/parser/kramdown/smart_quotes.rb
|
86
|
+
- lib/kramdown/parser/kramdown/table.rb
|
87
|
+
- lib/kramdown/parser/kramdown/typographic_symbol.rb
|
88
|
+
- lib/kramdown/parser/kramdown.rb
|
89
|
+
- lib/kramdown/parser/markdown.rb
|
90
|
+
- lib/kramdown/parser.rb
|
91
|
+
- lib/kramdown/utils/entities.rb
|
92
|
+
- lib/kramdown/utils/html.rb
|
93
|
+
- lib/kramdown/utils/ordered_hash.rb
|
94
|
+
- lib/kramdown/utils.rb
|
95
|
+
- lib/kramdown/version.rb
|
96
|
+
- lib/kramdown.rb
|
97
|
+
- COPYING
|
98
|
+
- GPL
|
99
|
+
- README
|
100
|
+
- AUTHORS
|
101
|
+
- VERSION
|
102
|
+
- ChangeLog
|
103
|
+
- CONTRIBUTERS
|
104
|
+
- bin/kramdown
|
105
|
+
homepage: http://github.com/thebeansgroup/kramdown
|
106
|
+
licenses: []
|
107
|
+
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options:
|
110
|
+
- --main
|
111
|
+
- README
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 1.8.17
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: bean-kramdown is a fast, pure-Ruby Markdown-superset converter.
|
139
|
+
test_files: []
|
140
|
+
|