wikicloth 0.8.0 → 0.8.1
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/.travis.yml +1 -1
- data/README.textile +3 -3
- data/examples/template_extractor.rb +68 -0
- data/lib/wikicloth/core_ext.rb +3 -5
- data/lib/wikicloth/extensions/math.rb +6 -1
- data/lib/wikicloth/extensions/references.rb +1 -1
- data/lib/wikicloth/extensions/source.rb +16 -4
- data/lib/wikicloth/i18n.rb +1 -1
- data/lib/wikicloth/parser.rb +6 -0
- data/lib/wikicloth/version.rb +1 -1
- data/lib/wikicloth/wiki_buffer.rb +2 -2
- data/lib/wikicloth/wiki_buffer/html_element.rb +1 -1
- data/lib/wikicloth/wiki_buffer/link.rb +8 -2
- data/lib/wikicloth/wiki_buffer/table.rb +4 -3
- data/lib/wikicloth/wiki_buffer/var.rb +6 -2
- data/lib/wikicloth/wiki_link_handler.rb +11 -7
- data/test/wiki_cloth_test.rb +47 -3
- data/wikicloth.gemspec +2 -0
- metadata +155 -135
data/.travis.yml
CHANGED
data/README.textile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
h1. WikiCloth "!https://
|
1
|
+
h1. WikiCloth "!https://api.travis-ci.org/nricciar/wikicloth.png!":https://travis-ci.org/nricciar/wikicloth
|
2
2
|
|
3
3
|
Ruby implementation of the MediaWiki markup language.
|
4
4
|
|
@@ -8,7 +8,7 @@ h2. Supports
|
|
8
8
|
* Links
|
9
9
|
** External Links [ ... ]
|
10
10
|
** Internal Links, Images [[ ... ]]
|
11
|
-
*
|
11
|
+
* Markup
|
12
12
|
** == Headings ==
|
13
13
|
** Lists (*#;:)
|
14
14
|
** bold (<code>'''</code>), italic (<code>''</code>) or both (<code>'''''</code>)
|
@@ -19,7 +19,7 @@ h2. Supports
|
|
19
19
|
* <code><ref></code> and <code><references/></code> support
|
20
20
|
* "html sanitization":https://github.com/nricciar/wikicloth/wiki/Html-Sanitization
|
21
21
|
|
22
|
-
For more information about the MediaWiki markup see "
|
22
|
+
For more information about the MediaWiki markup see "https://www.mediawiki.org/wiki/Markup_spec":https://www.mediawiki.org/wiki/Markup_spec
|
23
23
|
|
24
24
|
h2. Install
|
25
25
|
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Take a wiki document and extract the template options of the specified template
|
4
|
+
#
|
5
|
+
# {{Infobox person
|
6
|
+
# |name = Casanova
|
7
|
+
# |image = Casanova_self_portrait.jpg
|
8
|
+
# |caption = A self portrait of Casanova
|
9
|
+
# |website =
|
10
|
+
# }}
|
11
|
+
#
|
12
|
+
# and returns the template data in json...
|
13
|
+
#
|
14
|
+
# {"name":"Casanova","caption":"A self portrait of Casanova","website":"","image":"Casanova_self_portrait.jpg"}
|
15
|
+
#
|
16
|
+
# This file takes two arguments: filename, and template name
|
17
|
+
# ex: ./template_extractor test.wiki "Infobox person"
|
18
|
+
#
|
19
|
+
require File.join(File.dirname(__FILE__),'../init.rb')
|
20
|
+
require 'json'
|
21
|
+
|
22
|
+
class TemplateExtractor < WikiCloth::Parser
|
23
|
+
|
24
|
+
def initialize(args = {})
|
25
|
+
@templates = []
|
26
|
+
super(args)
|
27
|
+
to_html # parse the document
|
28
|
+
end
|
29
|
+
|
30
|
+
def extract(name)
|
31
|
+
ret = []
|
32
|
+
@templates.each do |template|
|
33
|
+
ret << template[:data] if template[:name] == name
|
34
|
+
end
|
35
|
+
ret.length == 1 ? ret.first : ret
|
36
|
+
end
|
37
|
+
|
38
|
+
link_for do |url,text|
|
39
|
+
text.blank? ? url : text
|
40
|
+
end
|
41
|
+
|
42
|
+
include_resource do |resource,options|
|
43
|
+
data = {}
|
44
|
+
options.each do |opt|
|
45
|
+
data[opt[:name]] = opt[:value]
|
46
|
+
end
|
47
|
+
@templates << { :name => resource, :data => data }
|
48
|
+
""
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
wiki_data = ""
|
54
|
+
if ARGV[0] && File.exists?(ARGV[0])
|
55
|
+
wiki_data = File.read(ARGV[0])
|
56
|
+
else
|
57
|
+
wiki_data = <<END_OF_DOC
|
58
|
+
{{Infobox person
|
59
|
+
|name = Casanova
|
60
|
+
|image = Casanova_self_portrait.jpg
|
61
|
+
|caption = A self portrait of Casanova
|
62
|
+
|website =
|
63
|
+
}}
|
64
|
+
END_OF_DOC
|
65
|
+
end
|
66
|
+
|
67
|
+
@wiki = TemplateExtractor.new(:data => wiki_data)
|
68
|
+
puts @wiki.extract(ARGV[1] ? ARGV[1] : "Infobox person").to_json
|
data/lib/wikicloth/core_ext.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rinku'
|
2
|
+
|
1
3
|
if RUBY_VERSION < '1.9'
|
2
4
|
READ_MODE = "r"
|
3
5
|
class Object
|
@@ -47,11 +49,7 @@ module ExtendedString
|
|
47
49
|
end
|
48
50
|
|
49
51
|
def auto_link
|
50
|
-
|
51
|
-
www_check = Regexp.new( '(^|[\n ])((www)\.[^ \"\t\n\r<]*)', Regexp::MULTILINE | Regexp::IGNORECASE )
|
52
|
-
self.gsub!(url_check, '\1<a href="\2">\2</a>')
|
53
|
-
self.gsub!(www_check, '\1<a href="http://\2">\2</a>')
|
54
|
-
to_s
|
52
|
+
Rinku.auto_link(to_s)
|
55
53
|
end
|
56
54
|
|
57
55
|
def last(n)
|
@@ -12,7 +12,12 @@ module WikiCloth
|
|
12
12
|
if File.exists?(blahtex_path) && @options[:math_formatter] != :google
|
13
13
|
begin
|
14
14
|
# pass tex markup to blahtex
|
15
|
-
response =
|
15
|
+
response = IO.popen("#{blahtex_path} #{blahtex_options} --png --mathml --png-directory #{blahtex_png_path}","w+") do |pipe|
|
16
|
+
pipe.write(buffer.element_content)
|
17
|
+
pipe.close_write
|
18
|
+
pipe.gets
|
19
|
+
end
|
20
|
+
|
16
21
|
xml_response = REXML::Document.new(response).root
|
17
22
|
|
18
23
|
if @options[:blahtex_html_prefix]
|
@@ -40,7 +40,7 @@ module WikiCloth
|
|
40
40
|
1.upto(r[:count]) { |x| ret += "<a href=\"#cite_ref-#{ref_name}#{ref_count}-#{x-1}\">" +
|
41
41
|
(r[:count] == 1 ? "^" : (x-1).to_s(26).tr('0-9a-p', 'a-z')) + "</a> " }
|
42
42
|
ret += "</b> #{r[:value]}</li>"
|
43
|
-
}.
|
43
|
+
}.join("\n")
|
44
44
|
"<ol>#{refs}</ol>"
|
45
45
|
end
|
46
46
|
|
@@ -1,5 +1,10 @@
|
|
1
|
+
begin
|
2
|
+
require 'pygments.rb'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
1
6
|
module WikiCloth
|
2
|
-
class
|
7
|
+
class SourceExtension < Extension
|
3
8
|
|
4
9
|
VALID_LANGUAGES = [ 'as','applescript','arm','asp','asm','awk','bat','bibtex','bbcode','bison','lua',
|
5
10
|
'bms','boo','c','c++','cc','cpp','cxx','h','hh','hpp','hxx','clojure','cbl','cob','cobol','cfc','cfm',
|
@@ -19,10 +24,17 @@ module WikiCloth
|
|
19
24
|
content = $1 if content =~ /^\s*\n(.*)$/m
|
20
25
|
error = nil
|
21
26
|
|
22
|
-
|
27
|
+
raise I18n.t("lang attribute is required") unless buffer.element_attributes.has_key?('lang')
|
28
|
+
raise I18n.t("unknown lang", :lang => buffer.element_attributes['lang'].downcase) unless SourceExtension::VALID_LANGUAGES.include?(buffer.element_attributes['lang'].downcase)
|
29
|
+
|
30
|
+
if defined?(Pygments)
|
31
|
+
begin
|
32
|
+
content = "<style type=\"text/css\">\n#{Pygments.css}\n</style>\n"+Pygments.highlight(content, :lexer => buffer.element_attributes['lang'].downcase).gsub!('<pre>', '').gsub!('</pre>', '')
|
33
|
+
rescue => err
|
34
|
+
error = "<span class=\"error\">#{err.message}</span>"
|
35
|
+
end
|
36
|
+
elsif File.exists?(highlight_path)
|
23
37
|
begin
|
24
|
-
raise I18n.t("lang attribute is required") unless buffer.element_attributes.has_key?('lang')
|
25
|
-
raise I18n.t("unknown lang", :lang => buffer.element_attributes['lang'].downcase) unless LuaExtension::VALID_LANGUAGES.include?(buffer.element_attributes['lang'].downcase)
|
26
38
|
IO.popen("#{highlight_path} #{highlight_options} -f --syntax #{buffer.element_attributes['lang'].downcase}", "r+") do |io|
|
27
39
|
io.puts content
|
28
40
|
io.close_write
|
data/lib/wikicloth/i18n.rb
CHANGED
@@ -22,7 +22,7 @@ module I18n
|
|
22
22
|
load_translations
|
23
23
|
use_locale = @@translations[locale].nil? || @@translations[locale].empty? ? default_locale : locale
|
24
24
|
|
25
|
-
if @@translations[use_locale].has_key?(key)
|
25
|
+
if !@@translations[use_locale].nil? && @@translations[use_locale].has_key?(key)
|
26
26
|
add_vars(@@translations[use_locale][key], options)
|
27
27
|
elsif use_locale != default_locale && @@translations[default_locale].has_key?(key)
|
28
28
|
add_vars(@@translations[default_locale][key], options)
|
data/lib/wikicloth/parser.rb
CHANGED
@@ -21,6 +21,12 @@ module WikiCloth
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
def image_url_for(&block)
|
25
|
+
self.send :define_method, 'image_url_for' do |url|
|
26
|
+
self.instance_exec(url, &block)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def toc(&block)
|
25
31
|
self.send :define_method, 'toc' do |sections, numbered|
|
26
32
|
self.instance_exec(sections, numbered, &block)
|
data/lib/wikicloth/version.rb
CHANGED
@@ -242,7 +242,7 @@ class WikiBuffer
|
|
242
242
|
|
243
243
|
def behavior_switch_key_name(name)
|
244
244
|
keys = [:toc,:notoc,:forcetoc,:noeditsection,:editsection]
|
245
|
-
locales = [@options[:locale],I18n.default_locale]
|
245
|
+
locales = [@options[:locale],I18n.default_locale,:en].uniq
|
246
246
|
values = {}
|
247
247
|
|
248
248
|
locales.each do |locale|
|
@@ -261,7 +261,7 @@ class WikiBuffer
|
|
261
261
|
"<h#{hnum}>" + (@options[:noedit] == true ? "" :
|
262
262
|
"<span class=\"editsection\">[<a href=\"" + @options[:link_handler].section_link(id) +
|
263
263
|
"\" title=\"#{I18n.t('edit section', :name => title)}\">#{I18n.t('edit')}</a>]</span> ") +
|
264
|
-
"<span class=\"mw-headline\" id=\"#{id}\"
|
264
|
+
"<a name=\"#{id}\"></a><span class=\"mw-headline\" id=\"#{id}\">#{title}</span></h#{hnum}>\n"
|
265
265
|
end
|
266
266
|
|
267
267
|
def get_id_for(val)
|
@@ -6,7 +6,7 @@ class WikiBuffer::HTMLElement < WikiBuffer
|
|
6
6
|
|
7
7
|
ALLOWED_ELEMENTS = ['a','b','i','img','div','span','sup','sub','strike','s','u','font','big','ref','tt','del',
|
8
8
|
'small','blockquote','strong','pre','code','references','ol','li','ul','dd','dt','dl','center',
|
9
|
-
'h1','h2','h3','h4','h5','h6','p','table','tr','td','th','tbody','thead','tfoot']
|
9
|
+
'h1','h2','h3','h4','h5','h6','p','table','tr','td','th','tbody','thead','tfoot','abbr','del','ins','em']
|
10
10
|
ALLOWED_ATTRIBUTES = ['src','id','name','style','class','href','start','value','colspan','align','border',
|
11
11
|
'cellpadding','cellspacing','name','valign','color','rowspan','nowrap','title','rel','for']
|
12
12
|
ESCAPED_TAGS = [ 'nowiki','pre','code' ]
|
@@ -14,8 +14,14 @@ class WikiBuffer::Link < WikiBuffer
|
|
14
14
|
|
15
15
|
def to_html
|
16
16
|
link_handler = @options[:link_handler]
|
17
|
-
unless self.internal_link || params[0].strip !~ /^\s*(([a-z]+):\/\/|[\?\/])/
|
18
|
-
|
17
|
+
unless self.internal_link || params[0].strip !~ /^\s*((([a-z]+):\/\/|mailto:)|[\?\/])(.*)/
|
18
|
+
if $1.downcase == "mailto:"
|
19
|
+
return link_handler.external_link("#{params[0]}".strip, $4)
|
20
|
+
elsif params.length > 1
|
21
|
+
return link_handler.external_link("#{params[0]}".strip, params.last.strip)
|
22
|
+
else
|
23
|
+
return link_handler.external_link("#{params[0]}".strip)
|
24
|
+
end
|
19
25
|
else
|
20
26
|
case
|
21
27
|
when !self.internal_link
|
@@ -61,7 +61,7 @@ class WikiBuffer::Table < WikiBuffer
|
|
61
61
|
when (char == '"' || char == "'") && in_quotes == false && !attribute_name.nil?
|
62
62
|
in_quotes = true
|
63
63
|
quote_type = char
|
64
|
-
when char == quote_type && in_quotes == true && prev_char != '\\'
|
64
|
+
when (char == quote_type && in_quotes == true && prev_char != '\\') || (char == ' ' && in_quotes == false && !d.blank?)
|
65
65
|
ret[attribute_name] = d if WikiBuffer::HTMLElement::ALLOWED_ATTRIBUTES.include?(attribute_name)
|
66
66
|
attribute_name = nil
|
67
67
|
in_quotes = false
|
@@ -105,7 +105,8 @@ class WikiBuffer::Table < WikiBuffer
|
|
105
105
|
def new_char()
|
106
106
|
if @check_cell_data == 1
|
107
107
|
case
|
108
|
-
when current_char != '|' && @start_caption == false && self.rows[-1][-1][:style].blank?
|
108
|
+
when current_char != '|' && @start_caption == false && (self.rows[-1][-1].nil? || self.rows[-1][-1][:style].blank?)
|
109
|
+
self.next_cell() if self.rows[-1][-1].nil?
|
109
110
|
self.rows[-1][-1][:style] = self.data
|
110
111
|
self.data = ""
|
111
112
|
when current_char != '|' && @start_caption == true && self.table_caption_attributes.blank?
|
@@ -118,7 +119,7 @@ class WikiBuffer::Table < WikiBuffer
|
|
118
119
|
case
|
119
120
|
# Next table cell in row (TD)
|
120
121
|
when current_char == "|" && (previous_char == "\n" || previous_char == "|") && @in_quotes == false
|
121
|
-
self.data.chop!
|
122
|
+
self.data.chop! if self.data[-1,1] == "|"
|
122
123
|
self.next_cell() unless self.data.blank? && previous_char == "|"
|
123
124
|
self.data = ""
|
124
125
|
|
@@ -257,8 +257,12 @@ class WikiBuffer::Var < WikiBuffer
|
|
257
257
|
|
258
258
|
# Start of either a function or a namespace change
|
259
259
|
when current_char == ':' && @in_quotes == false && self.params.size <= 1
|
260
|
-
self.
|
261
|
-
|
260
|
+
if self.data.blank? || self.data.include?(":")
|
261
|
+
self.data << current_char
|
262
|
+
else
|
263
|
+
self.function_name = self.data
|
264
|
+
self.data = ""
|
265
|
+
end
|
262
266
|
|
263
267
|
# Dealing with variable names within functions
|
264
268
|
# and variables
|
@@ -41,7 +41,7 @@ class WikiLinkHandler < WikiNamespaces
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def toc(sections, toc_numbered=false)
|
44
|
-
ret = "<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div
|
44
|
+
ret = "<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div id=\"toctitle\"><h2>#{I18n.t('table of contents')}</h2></div><ul>"
|
45
45
|
previous_depth = 1
|
46
46
|
indices = []
|
47
47
|
section_list(sections).each do |section|
|
@@ -114,9 +114,9 @@ class WikiLinkHandler < WikiNamespaces
|
|
114
114
|
@params = val
|
115
115
|
end
|
116
116
|
|
117
|
-
def external_link(url,text)
|
117
|
+
def external_link(url,text=nil)
|
118
118
|
self.external_links << url
|
119
|
-
elem.a({ :href => url, :target => "_blank" }) { |x| x << (text.blank? ? url : text) }
|
119
|
+
elem.a({ :href => url, :target => "_blank" }) { |x| x << (text.nil? || text.blank? ? url : text) }
|
120
120
|
end
|
121
121
|
|
122
122
|
def external_links=(val)
|
@@ -131,6 +131,10 @@ class WikiLinkHandler < WikiNamespaces
|
|
131
131
|
"#{page}"
|
132
132
|
end
|
133
133
|
|
134
|
+
def image_url_for(image)
|
135
|
+
"#{image}"
|
136
|
+
end
|
137
|
+
|
134
138
|
def link_attributes_for(page)
|
135
139
|
{ :href => url_for(page) }
|
136
140
|
end
|
@@ -172,7 +176,7 @@ class WikiLinkHandler < WikiNamespaces
|
|
172
176
|
prefix.downcase!
|
173
177
|
case
|
174
178
|
when (MEDIA_NAMESPACES+FILE_NAMESPACES).include?(prefix)
|
175
|
-
ret += wiki_image(resource,options)
|
179
|
+
ret += wiki_image(resource,options,prefix)
|
176
180
|
when CATEGORY_NAMESPACES.include?(prefix)
|
177
181
|
self.categories << resource
|
178
182
|
when LANGUAGE_NAMESPACES.include?(prefix)
|
@@ -192,7 +196,7 @@ class WikiLinkHandler < WikiNamespaces
|
|
192
196
|
end
|
193
197
|
|
194
198
|
# this code needs some work... lots of work
|
195
|
-
def wiki_image(resource,options)
|
199
|
+
def wiki_image(resource,options,prefix='Image')
|
196
200
|
pre_img = ''
|
197
201
|
post_img = ''
|
198
202
|
css = []
|
@@ -228,10 +232,10 @@ class WikiLinkHandler < WikiNamespaces
|
|
228
232
|
sane_title = title.nil? ? "" : title.gsub(/<\/?[^>]*>/, "")
|
229
233
|
if ["thumb","thumbnail","frame","miniatur"].include?(type)
|
230
234
|
pre_img = '<div class="thumb t' + loc + '"><div class="thumbinner" style="width: ' + w.to_s +
|
231
|
-
'px;"><a href="" class="image" title="' + sane_title + '">'
|
235
|
+
'px;"><a href="' + url_for("#{prefix.capitalize}:#{resource}") + '" class="image" title="' + sane_title + '">'
|
232
236
|
post_img = '</a><div class="thumbcaption">' + title + '</div></div></div>'
|
233
237
|
end
|
234
|
-
"#{pre_img}<img src=\"#{resource}\" alt=\"#{sane_title}\" title=\"#{sane_title}\" style=\"#{css.join(";")}\" />#{post_img}"
|
238
|
+
"#{pre_img}<img src=\"#{image_url_for(resource)}\" alt=\"#{sane_title}\" title=\"#{sane_title}\" style=\"#{css.join(";")}\" />#{post_img}"
|
235
239
|
end
|
236
240
|
|
237
241
|
def elem
|
data/test/wiki_cloth_test.rb
CHANGED
@@ -6,6 +6,10 @@ class WikiParser < WikiCloth::Parser
|
|
6
6
|
page
|
7
7
|
end
|
8
8
|
|
9
|
+
image_url_for do |url|
|
10
|
+
File.join("/images/", url)
|
11
|
+
end
|
12
|
+
|
9
13
|
template do |template|
|
10
14
|
case template
|
11
15
|
when "noinclude"
|
@@ -35,6 +39,46 @@ end
|
|
35
39
|
|
36
40
|
class WikiClothTest < ActiveSupport::TestCase
|
37
41
|
|
42
|
+
test "a url should be automaticly linked" do
|
43
|
+
wiki = WikiCloth::Parser.new(:data => "\n\n\nhttp://www.google.com/")
|
44
|
+
data = wiki.to_html
|
45
|
+
assert data.include?('<a href="http://www.google.com/">')
|
46
|
+
wiki = WikiCloth::Parser.new(:data => "hello http://www.google.com/ world")
|
47
|
+
data = wiki.to_html
|
48
|
+
assert data.include?('<a href="http://www.google.com/">')
|
49
|
+
wiki = WikiCloth::Parser.new(:data => "http://www.google.com/")
|
50
|
+
data = wiki.to_html
|
51
|
+
assert data.include?('<a href="http://www.google.com/">')
|
52
|
+
wiki = WikiCloth::Parser.new(:data => "[https://github.com/repo/README.md README]")
|
53
|
+
data = wiki.to_html
|
54
|
+
assert data.include?('https://github.com/repo/README.md')
|
55
|
+
assert data =~ /\>\s*README\s*\</
|
56
|
+
end
|
57
|
+
|
58
|
+
test "image url override" do
|
59
|
+
wiki = WikiCloth::Parser.new(:data => "[[Image:test.jpg]]")
|
60
|
+
data = wiki.to_html
|
61
|
+
assert !data.include?("/images/test.jpg")
|
62
|
+
assert data.include?("\"test.jpg\"")
|
63
|
+
|
64
|
+
wiki = WikiParser.new(:data => "[[Image:test.jpg]]")
|
65
|
+
data = wiki.to_html
|
66
|
+
assert data.include?("/images/test.jpg")
|
67
|
+
end
|
68
|
+
|
69
|
+
test "wiki table attributes without quotes" do
|
70
|
+
wiki = WikiParser.new(:data => "{| width=\"95%\"
|
71
|
+
!colspan=2 style=\"background-color:#ffebac;\"|Heading
|
72
|
+
|-
|
73
|
+
|hello||world
|
74
|
+
|}")
|
75
|
+
data = wiki.to_html
|
76
|
+
assert data.include?("<table width=\"95%\">")
|
77
|
+
assert data.include?("colspan=\"2\"")
|
78
|
+
assert data.include?("hello")
|
79
|
+
assert data.include?("world")
|
80
|
+
end
|
81
|
+
|
38
82
|
test "nested bold/italic markup" do
|
39
83
|
wiki = WikiParser.new(:data => "''Mars goes around the Sun once in a Martian '''year''', or 1.88 Earth '''years'''.''")
|
40
84
|
data = wiki.to_html
|
@@ -396,7 +440,7 @@ EOS
|
|
396
440
|
test "empty item in toc" do
|
397
441
|
wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A="})
|
398
442
|
data = wiki.render
|
399
|
-
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div
|
443
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div id=\"toctitle\"><h2>Table of Contents</h2></div><ul></li><li><a href=\"#A\">A</a></li></ul></td></tr></table>")
|
400
444
|
end
|
401
445
|
|
402
446
|
test "pre at beginning" do
|
@@ -408,12 +452,12 @@ EOS
|
|
408
452
|
test "toc declared as list" do
|
409
453
|
wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A=\n==B==\n===C==="})
|
410
454
|
data = wiki.render
|
411
|
-
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div
|
455
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div id=\"toctitle\"><h2>Table of Contents</h2></div><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></td></tr></table>")
|
412
456
|
end
|
413
457
|
|
414
458
|
test "toc numbered" do
|
415
459
|
wiki = WikiCloth::WikiCloth.new({:data => "=A=\n=B=\n==C==\n==D==\n===E===\n===F===\n====G====\n====H====\n==I==\n=J=\n=K=\n===L===\n===M===\n====N====\n====O===="})
|
416
460
|
data = wiki.render(:noedit => true, :toc_numbered => true)
|
417
|
-
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div
|
461
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div id=\"toctitle\"><h2>Table of Contents</h2></div><ul></li><li><a href=\"#A\">1 A</a></li><li><a href=\"#B\">2 B</a><ul><li><a href=\"#C\">2.1 C</a></li><li><a href=\"#D\">2.2 D</a><ul><li><a href=\"#E\">2.2.1 E</a></li><li><a href=\"#F\">2.2.2 F</a><ul><li><a href=\"#G\">2.2.2.1 G</a></li><li><a href=\"#H\">2.2.2.2 H</a></li></ul></ul><li><a href=\"#I\">2.3 I</a></li></ul><li><a href=\"#J\">3 J</a></li><li><a href=\"#K\">4 K</a><ul><ul><li><a href=\"#L\">4.1 L</a></li><li><a href=\"#M\">4.2 M</a><ul><li><a href=\"#N\">4.2.1 N</a></li><li><a href=\"#O\">4.2.2 O</a></li></ul></ul></ul></ul></td></tr></table>")
|
418
462
|
end
|
419
463
|
end
|
data/wikicloth.gemspec
CHANGED
@@ -19,8 +19,10 @@ spec = Gem::Specification.new do |s|
|
|
19
19
|
s.has_rdoc = false
|
20
20
|
s.extra_rdoc_files = ["README","MIT-LICENSE"]
|
21
21
|
s.description = %q{mediawiki parser}
|
22
|
+
s.license = "MIT"
|
22
23
|
s.add_dependency 'builder'
|
23
24
|
s.add_dependency 'expression_parser'
|
25
|
+
s.add_dependency 'rinku'
|
24
26
|
s.add_development_dependency 'test-unit'
|
25
27
|
s.add_development_dependency 'activesupport'
|
26
28
|
s.add_development_dependency 'i18n'
|
metadata
CHANGED
@@ -1,145 +1,168 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikicloth
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 8
|
9
|
-
- 0
|
10
|
-
version: 0.8.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- David Ricciardi
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: builder
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
36
31
|
name: expression_parser
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
37
39
|
prerelease: false
|
38
|
-
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rinku
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
47
54
|
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: test-unit
|
51
55
|
prerelease: false
|
52
|
-
|
53
|
-
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: test-unit
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
61
70
|
type: :development
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: activesupport
|
65
71
|
prerelease: false
|
66
|
-
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: activesupport
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
75
86
|
type: :development
|
76
|
-
version_requirements: *id004
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
name: i18n
|
79
87
|
prerelease: false
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: i18n
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
89
102
|
type: :development
|
90
|
-
version_requirements: *id005
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
name: rake
|
93
103
|
prerelease: false
|
94
|
-
|
95
|
-
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
103
118
|
type: :development
|
104
|
-
version_requirements: *id006
|
105
|
-
- !ruby/object:Gem::Dependency
|
106
|
-
name: rdoc
|
107
119
|
prerelease: false
|
108
|
-
|
109
|
-
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rdoc
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
117
134
|
type: :development
|
118
|
-
version_requirements: *id007
|
119
|
-
- !ruby/object:Gem::Dependency
|
120
|
-
name: rcov
|
121
135
|
prerelease: false
|
122
|
-
|
123
|
-
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: simplecov
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
131
150
|
type: :development
|
132
|
-
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
133
158
|
description: mediawiki parser
|
134
159
|
email: nricciar@gmail.com
|
135
160
|
executables: []
|
136
|
-
|
137
161
|
extensions: []
|
138
|
-
|
139
|
-
extra_rdoc_files:
|
162
|
+
extra_rdoc_files:
|
140
163
|
- README
|
141
164
|
- MIT-LICENSE
|
142
|
-
files:
|
165
|
+
files:
|
143
166
|
- .gitignore
|
144
167
|
- .travis.yml
|
145
168
|
- Gemfile
|
@@ -149,6 +172,7 @@ files:
|
|
149
172
|
- Rakefile
|
150
173
|
- examples/info.rb
|
151
174
|
- examples/print.rb
|
175
|
+
- examples/template_extractor.rb
|
152
176
|
- init.rb
|
153
177
|
- lang/de.yml
|
154
178
|
- lang/en.yml
|
@@ -193,39 +217,35 @@ files:
|
|
193
217
|
- test/test_helper.rb
|
194
218
|
- test/wiki_cloth_test.rb
|
195
219
|
- wikicloth.gemspec
|
196
|
-
has_rdoc: true
|
197
220
|
homepage: http://github.com/nricciar/wikicloth
|
198
|
-
licenses:
|
199
|
-
|
221
|
+
licenses:
|
222
|
+
- MIT
|
200
223
|
post_install_message:
|
201
224
|
rdoc_options: []
|
202
|
-
|
203
|
-
require_paths:
|
225
|
+
require_paths:
|
204
226
|
- lib
|
205
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
227
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
228
|
none: false
|
207
|
-
requirements:
|
208
|
-
- -
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
|
211
|
-
segments:
|
229
|
+
requirements:
|
230
|
+
- - ! '>='
|
231
|
+
- !ruby/object:Gem::Version
|
232
|
+
version: '0'
|
233
|
+
segments:
|
212
234
|
- 0
|
213
|
-
|
214
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
235
|
+
hash: -2603482441025638053
|
236
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
237
|
none: false
|
216
|
-
requirements:
|
217
|
-
- -
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
|
220
|
-
segments:
|
238
|
+
requirements:
|
239
|
+
- - ! '>='
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: '0'
|
242
|
+
segments:
|
221
243
|
- 0
|
222
|
-
|
244
|
+
hash: -2603482441025638053
|
223
245
|
requirements: []
|
224
|
-
|
225
246
|
rubyforge_project:
|
226
|
-
rubygems_version: 1.
|
247
|
+
rubygems_version: 1.8.25
|
227
248
|
signing_key:
|
228
249
|
specification_version: 3
|
229
250
|
summary: An implementation of the mediawiki markup in ruby
|
230
251
|
test_files: []
|
231
|
-
|