tocmd 0.0.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.
- checksums.yaml +7 -0
- data/bin/tocmd +70 -0
- data/lib/mdpreview/markdown_render.rb +45 -0
- data/lib/mdpreview/translator.rb +237 -0
- data/lib/mdpreview/version.rb +3 -0
- data/lib/mdpreview.rb +18 -0
- data/test/mdptest.rb +100 -0
- data/vendor/cur.file +6 -0
- data/vendor/meta.js +1 -0
- data/vendor/template.html +0 -0
- data/vendor/toc/css/demo.css +33 -0
- data/vendor/toc/css/zTreeStyle/img/diy/1_close.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/1_open.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/2.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/3.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/4.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/5.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/6.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/7.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/8.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/diy/9.png +0 -0
- data/vendor/toc/css/zTreeStyle/img/line_conn.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/loading.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/zTreeStandard.gif +0 -0
- data/vendor/toc/css/zTreeStyle/img/zTreeStandard.png +0 -0
- data/vendor/toc/css/zTreeStyle/zTreeStyle.css +97 -0
- data/vendor/toc/js/jquery-1.4.4.min.js +167 -0
- data/vendor/toc/js/jquery.ztree.all-3.5.js +3447 -0
- data/vendor/toc/js/jquery.ztree.all-3.5.min.js +157 -0
- data/vendor/toc/js/jquery.ztree.core-3.5.js +1644 -0
- data/vendor/toc/js/jquery.ztree.core-3.5.min.js +68 -0
- data/vendor/toc/js/jquery.ztree.excheck-3.5.js +624 -0
- data/vendor/toc/js/jquery.ztree.excheck-3.5.min.js +33 -0
- data/vendor/toc/js/jquery.ztree.exedit-3.5.js +1178 -0
- data/vendor/toc/js/jquery.ztree.exedit-3.5.min.js +52 -0
- data/vendor/toc/js/jquery.ztree.exhide-3.5.js +362 -0
- data/vendor/toc/js/jquery.ztree.exhide-3.5.min.js +22 -0
- data/vendor/toc/js/jquery.ztree_toc.js +224 -0
- data/vendor/toc/js/jquery.ztree_toc.min.js +4 -0
- data/vendor/toc/style/Clearness Dark.css +146 -0
- data/vendor/toc/style/Clearness.css +147 -0
- data/vendor/toc/style/GitHub.css +90 -0
- data/vendor/toc/style/GitHub2.css +297 -0
- data/vendor/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css +1 -0
- data/vendor/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css +1 -0
- data/vendor/toc/style/makedownpad.css +285 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d905d846ac396dbede31f27fa7f07567d472fbb
|
4
|
+
data.tar.gz: 47275da1ce1e7d5c29b3526404a93949a3cf497d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc2d6a9c370b3858ae3ddf9e9b8e1be5ab3e5e3fba660426d9d8f426191f06dc47cb35939281bd720775e104045e74325cf205b0da9a6f5146606251a12ad48d
|
7
|
+
data.tar.gz: 60d3b63158fcefc176df99405b3270bdad5deb344e0d684622b16e814362751752e606ce7244ea2e29496d0d452e512ce0cf8efe2024a8d6bff801836be9eace
|
data/bin/tocmd
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'mdpreview'
|
5
|
+
require 'pathname'
|
6
|
+
# p ARGV
|
7
|
+
# puts Mdpreview.hi(ARGV)
|
8
|
+
|
9
|
+
# puts __FILE__
|
10
|
+
# puts File.dirname(__FILE__)
|
11
|
+
|
12
|
+
|
13
|
+
# File.join(File.dirname(__FILE__), '..', 'lib')
|
14
|
+
path = Pathname.new(File.join(File.dirname(__FILE__), '..')).realpath.to_s
|
15
|
+
|
16
|
+
p "开始"
|
17
|
+
|
18
|
+
require 'optparse'
|
19
|
+
|
20
|
+
options = {}
|
21
|
+
option_parser = OptionParser.new do |opts|
|
22
|
+
# 这里是这个命令行工具的帮助信息
|
23
|
+
opts.banner = 'preview markdown file with toc of the command line tool.'
|
24
|
+
|
25
|
+
# # Option 作为switch,不带argument,用于将switch设置成true或false
|
26
|
+
# options[:switch] = false
|
27
|
+
# # 下面第一项是Short option(没有可以直接在引号间留空),第二项是Long option,第三项是对Option的描述
|
28
|
+
# opts.on('-s', '--switch', 'Set options as switch') do
|
29
|
+
# # 这个部分就是使用这个Option后执行的代码
|
30
|
+
# options[:switch] = true
|
31
|
+
# end
|
32
|
+
vendor_path = Pathname.new(File.expand_path('../../vendor/', __FILE__)).realpath.to_s
|
33
|
+
|
34
|
+
begin
|
35
|
+
Dir.delelte(File.join(path ,"preview"))
|
36
|
+
Dir.mkdir(File.join(path ,"preview"), 0700) #=> 0
|
37
|
+
rescue
|
38
|
+
ensure
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
Dir.mkdir(File.join(path ,"preview"), 0700) #=> 0
|
43
|
+
rescue
|
44
|
+
ensure
|
45
|
+
end
|
46
|
+
|
47
|
+
begin
|
48
|
+
Dir.mkdir(File.join(path ,".toc"), 0700) #=> 0
|
49
|
+
rescue
|
50
|
+
ensure
|
51
|
+
f = File.new(File.join(vendor_path ,"template.html"), "w+").path
|
52
|
+
FileUtils.cp(f ,File.join(path ,".toc"))
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
# Option 作为flag,带argument,用于将argument作为数值解析,比如"name"信息
|
57
|
+
#下面的“value”就是用户使用时输入的argument
|
58
|
+
opts.on('-f sourceFileNAME', '--name sourceFileNAME', 'Pass-in source file name') do |value|
|
59
|
+
# options[:fname] = value
|
60
|
+
|
61
|
+
Mdpreview.hi(path + '/' + value)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Option 作为flag,带一组用逗号分割的arguments,用于将arguments作为数组解析
|
65
|
+
# opts.on('-a A,B', '--array A,B', Array, 'List of arguments') do |value|
|
66
|
+
# options[:array] = value
|
67
|
+
# end
|
68
|
+
end.parse!
|
69
|
+
|
70
|
+
# puts options.inspect
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'pygments'
|
3
|
+
|
4
|
+
require 'redcarpet'
|
5
|
+
require 'rexml/document'
|
6
|
+
module Redcarpet::Render
|
7
|
+
class Custom < Base
|
8
|
+
def header(title, level)
|
9
|
+
@headers ||= []
|
10
|
+
|
11
|
+
title_elements = REXML::Document.new(title)
|
12
|
+
flattened_title = title_elements.inject('') do |flattened, element|
|
13
|
+
flattened += if element.respond_to?(:text)
|
14
|
+
element.text
|
15
|
+
else
|
16
|
+
element.to_s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
permalink = flattened_title.downcase.gsub(/[^a-z\s]/, '').gsub(/\W+/, "-")
|
20
|
+
|
21
|
+
# for extra credit: implement this as its own method
|
22
|
+
if @headers.include?(permalink)
|
23
|
+
permalink += "_1"
|
24
|
+
# my brain hurts
|
25
|
+
loop do
|
26
|
+
break if !@headers.include?(permalink)
|
27
|
+
# generate titles like foo-bar_1, foo-bar_2
|
28
|
+
permalink.gsub!(/\_(\d+)$/, "_#{$1.to_i + 1}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@headers << permalink
|
32
|
+
%(\n<h#{level}><a name="#{permalink}" class="anchor" href="##{permalink}"><span class="anchor-icon"></span></a>#{title}</h#{level}>\n)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class HTMLwithPygments < Redcarpet::Render::HTML
|
38
|
+
def doc_header()
|
39
|
+
'<style>' + Pygments.css('.highlight',:style => 'friendly') + '</style>'
|
40
|
+
end
|
41
|
+
|
42
|
+
def block_code(code, language)
|
43
|
+
Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'})
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,237 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'FileUtils'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
class Mdpreview::Translator
|
7
|
+
def initialize(source_file_path)
|
8
|
+
#源文件路径
|
9
|
+
@source_file_path = source_file_path
|
10
|
+
#gem跟目录
|
11
|
+
@gem_root_path = File.expand_path('../', @source_file_path)
|
12
|
+
#editor path
|
13
|
+
@editor_path = Pathname.new(File.expand_path('../../../vendor', __FILE__)).realpath.to_s
|
14
|
+
|
15
|
+
p "@gem root_path:::"+@gem_root_path
|
16
|
+
p "@src file_path:::"+@source_file_path
|
17
|
+
p "@editor path :::"+@editor_path
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def hi
|
22
|
+
generate_meta_js
|
23
|
+
cp_source_file_to_cur_file
|
24
|
+
open_in_browser
|
25
|
+
|
26
|
+
ar = @source_file_path.split('/')
|
27
|
+
ar.pop()
|
28
|
+
|
29
|
+
puts "src path = #{ar.join('/').to_s}"
|
30
|
+
src_path = ar.join('/').to_s
|
31
|
+
|
32
|
+
ar.push('preview');
|
33
|
+
dest_dir = ar.join('/').to_s
|
34
|
+
|
35
|
+
puts "desc path = #{ar.join('/').to_s}"
|
36
|
+
|
37
|
+
build_with_dir(src_path ,dest_dir)
|
38
|
+
end
|
39
|
+
|
40
|
+
def open_in_browser
|
41
|
+
`open #{@editor_path}/jsoneditor-2.3.6/examples/main.html`
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_meta_js
|
45
|
+
f = File.new(File.join(@editor_path,"meta.js"), "w+")
|
46
|
+
f.puts("#{@source_file_path}")
|
47
|
+
end
|
48
|
+
|
49
|
+
def cp_source_file_to_cur_file
|
50
|
+
# cp param must be string
|
51
|
+
f = File.new(File.join(@editor_path,"cur.file"), "w+").path
|
52
|
+
FileUtils.cp(@source_file_path,f)
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_with_dir(destiny_dir,dest_dir)
|
56
|
+
Dir.foreach(destiny_dir) do |ff|
|
57
|
+
# puts ff
|
58
|
+
unless /^\./ =~ ff ||/^images/ =~ ff ||/^css/ =~ ff || File.directory?(ff) || File.extname(ff) != '.md'
|
59
|
+
|
60
|
+
puts "src = #{ff}"
|
61
|
+
|
62
|
+
# get markdown text
|
63
|
+
text = IO.read(destiny_dir + '/' + ff)
|
64
|
+
|
65
|
+
# options = [:fenced_code,:generate_toc,:hard_wrap,:no_intraemphasis,:strikethrough,:gh_blockcode,:autolink,:xhtml,:tables]
|
66
|
+
|
67
|
+
# convert to html
|
68
|
+
markdown = Redcarpet::Markdown.new(HTMLwithPygments,:gh_blockcode=>true,:no_intra_emphasis=>true,:filter_html => true,:hard_wrap => true,:autolink => true, :space_after_headers => true,:fenced_code_blocks => true)
|
69
|
+
parse_markdown = markdown.render(text)
|
70
|
+
# parse_markdown = syntax_highlighter(parse_markdown)
|
71
|
+
|
72
|
+
css_link = ''
|
73
|
+
if destiny_dir.to_s.index('/')
|
74
|
+
css_link = %Q{
|
75
|
+
<link href="#{@editor_path}/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css" media="all" rel="stylesheet" type="text/css"/>
|
76
|
+
<link href="#{@editor_path}/toc//style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css" media="all" rel="stylesheet" type="text/css"/>
|
77
|
+
<link href="#{@editor_path}/toc/css/zTreeStyle/zTreeStyle.css" media="all" rel="stylesheet" type="text/css"/>
|
78
|
+
}
|
79
|
+
else
|
80
|
+
css_link = %Q{
|
81
|
+
<link href="#{@editor_path}/toc/style/github-bf51422f4bb36427d391e4b75a1daa083c2d840e.css" media="all" rel="stylesheet" type="text/css"/>
|
82
|
+
<link href="#{@editor_path}/toc/style/github2-d731afd4f624c99a4b19ad69f3083cd6d02b81d5.css" media="all" rel="stylesheet" type="text/css"/>
|
83
|
+
<link href="#{@editor_path}/toc/css/zTreeStyle/zTreeStyle.css" media="all" rel="stylesheet" type="text/css"/>
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
t = %Q{
|
88
|
+
<html>
|
89
|
+
<head>
|
90
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
91
|
+
<title>#{ff.gsub('.md','')}</title>
|
92
|
+
#{css_link}
|
93
|
+
<style>
|
94
|
+
pre {
|
95
|
+
counter-reset: line-numbering;
|
96
|
+
border: solid 1px #d9d9d9;
|
97
|
+
border-radius: 0;
|
98
|
+
background: #fff;
|
99
|
+
padding: 0;
|
100
|
+
line-height: 23px;
|
101
|
+
margin-bottom: 30px;
|
102
|
+
white-space: pre;
|
103
|
+
overflow-x: auto;
|
104
|
+
word-break: inherit;
|
105
|
+
word-wrap: inherit;
|
106
|
+
}
|
107
|
+
|
108
|
+
pre a::before {
|
109
|
+
content: counter(line-numbering);
|
110
|
+
counter-increment: line-numbering;
|
111
|
+
padding-right: 1em; /* space after numbers */
|
112
|
+
width: 25px;
|
113
|
+
text-align: right;
|
114
|
+
opacity: 0.7;
|
115
|
+
display: inline-block;
|
116
|
+
color: #aaa;
|
117
|
+
background: #eee;
|
118
|
+
margin-right: 16px;
|
119
|
+
padding: 2px 10px;
|
120
|
+
font-size: 13px;
|
121
|
+
-webkit-touch-callout: none;
|
122
|
+
-webkit-user-select: none;
|
123
|
+
-khtml-user-select: none;
|
124
|
+
-moz-user-select: none;
|
125
|
+
-ms-user-select: none;
|
126
|
+
user-select: none;
|
127
|
+
}
|
128
|
+
|
129
|
+
pre a:first-of-type::before {
|
130
|
+
padding-top: 10px;
|
131
|
+
}
|
132
|
+
|
133
|
+
pre a:last-of-type::before {
|
134
|
+
padding-bottom: 10px;
|
135
|
+
}
|
136
|
+
|
137
|
+
pre a:only-of-type::before {
|
138
|
+
padding: 10px;
|
139
|
+
}
|
140
|
+
|
141
|
+
.highlight { background-color: #ffffcc } /* RIGHT */
|
142
|
+
</style>
|
143
|
+
</head>
|
144
|
+
<body>
|
145
|
+
<div>
|
146
|
+
|
147
|
+
</div>
|
148
|
+
<div id='readme' style='width:834px;margin:20px auto'>
|
149
|
+
<ul id="tree" class="ztree" style="">
|
150
|
+
|
151
|
+
</ul>
|
152
|
+
<article class='markdown-body'>
|
153
|
+
#{parse_markdown}
|
154
|
+
</article>
|
155
|
+
</div>
|
156
|
+
</body>
|
157
|
+
</html>
|
158
|
+
<script type="text/javascript" src="#{@editor_path}/toc/js/jquery-1.4.4.min.js"></script>
|
159
|
+
<script type="text/javascript" src="#{@editor_path}/toc/js/jquery.ztree.core-3.5.js"></script>
|
160
|
+
<script type="text/javascript" src="#{@editor_path}/toc/js/jquery.ztree_toc.min.js"></script>
|
161
|
+
<SCRIPT type="text/javascript" >
|
162
|
+
<!--
|
163
|
+
$(document).ready(function(){
|
164
|
+
$('#tree').ztree_toc({
|
165
|
+
|
166
|
+
});
|
167
|
+
});
|
168
|
+
//-->
|
169
|
+
</SCRIPT>
|
170
|
+
}
|
171
|
+
|
172
|
+
if destiny_dir.to_s.index('/')
|
173
|
+
p '1build src/' + destiny_dir.to_s.split('/')[1] + '/' + ff.gsub('.md','') + '.html'
|
174
|
+
build_dir = 'preview/'
|
175
|
+
|
176
|
+
p 'build = ' + dest_dir + ff.gsub('.md','') + '.html'
|
177
|
+
IO.write(dest_dir + '/' + ff.gsub('.md','') + '.html',t) # => 10
|
178
|
+
else
|
179
|
+
p '2build src/' + ff.gsub('.md','') + '.html'
|
180
|
+
build_dir = 'preview/'
|
181
|
+
# write to html file
|
182
|
+
IO.write(build_dir + '/' + ff.gsub('.md','') + '.html',t) # => 10
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
require 'redcarpet'
|
194
|
+
require 'pygments'
|
195
|
+
|
196
|
+
require 'redcarpet'
|
197
|
+
require 'rexml/document'
|
198
|
+
module Redcarpet::Render
|
199
|
+
class Custom < Base
|
200
|
+
def header(title, level)
|
201
|
+
@headers ||= []
|
202
|
+
|
203
|
+
title_elements = REXML::Document.new(title)
|
204
|
+
flattened_title = title_elements.inject('') do |flattened, element|
|
205
|
+
flattened += if element.respond_to?(:text)
|
206
|
+
element.text
|
207
|
+
else
|
208
|
+
element.to_s
|
209
|
+
end
|
210
|
+
end
|
211
|
+
permalink = flattened_title.downcase.gsub(/[^a-z\s]/, '').gsub(/\W+/, "-")
|
212
|
+
|
213
|
+
# for extra credit: implement this as its own method
|
214
|
+
if @headers.include?(permalink)
|
215
|
+
permalink += "_1"
|
216
|
+
# my brain hurts
|
217
|
+
loop do
|
218
|
+
break if !@headers.include?(permalink)
|
219
|
+
# generate titles like foo-bar_1, foo-bar_2
|
220
|
+
permalink.gsub!(/\_(\d+)$/, "_#{$1.to_i + 1}")
|
221
|
+
end
|
222
|
+
end
|
223
|
+
@headers << permalink
|
224
|
+
%(\n<h#{level}><a name="#{permalink}" class="anchor" href="##{permalink}"><span class="anchor-icon"></span></a>#{title}</h#{level}>\n)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
class HTMLwithPygments < Redcarpet::Render::HTML
|
230
|
+
def doc_header()
|
231
|
+
'<style>' + Pygments.css('.highlight',:style => 'friendly') + '</style>'
|
232
|
+
end
|
233
|
+
|
234
|
+
def block_code(code, language)
|
235
|
+
Pygments.highlight(code, :lexer => language, :options => {:encoding => 'utf-8'})
|
236
|
+
end
|
237
|
+
end
|
data/lib/mdpreview.rb
ADDED
data/test/mdptest.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
#
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'mdpreview'
|
6
|
+
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
#
|
8
|
+
#
|
9
|
+
#
|
10
|
+
# 各assertion的最后一个参数message表示测试失败时显示的消息
|
11
|
+
#
|
12
|
+
# assert(boolean, message="")
|
13
|
+
# 若boolean为真则pass
|
14
|
+
#
|
15
|
+
# assert_equal(expected, actual, message=nil)
|
16
|
+
# 若expected == actual则pass
|
17
|
+
#
|
18
|
+
# assert_not_equal(expected, actual, message="")
|
19
|
+
# 若expected != actual则pass
|
20
|
+
#
|
21
|
+
# assert_instance_of(klass, object, message="")
|
22
|
+
# 若klass == object.class为真则pass
|
23
|
+
#
|
24
|
+
# assert_nil(object, message="")
|
25
|
+
# 若object.nil?则pass
|
26
|
+
#
|
27
|
+
# assert_not_nil(object, message="")
|
28
|
+
# 若!object.nil?则pass
|
29
|
+
#
|
30
|
+
# assert_kind_of(klass, object, message="")
|
31
|
+
# 若object.kind_of?(klass)为真则pass
|
32
|
+
#
|
33
|
+
# assert_respond_to(object, method, message="")
|
34
|
+
# 若object.respond_to?(method)为真则pass
|
35
|
+
#
|
36
|
+
# assert_match(pattern, string, message="")
|
37
|
+
# 若string =~ pattern为真则pass
|
38
|
+
#
|
39
|
+
# assert_no_match(regexp, string, message="")
|
40
|
+
# 若regexp !~ string为真则pass
|
41
|
+
#
|
42
|
+
# assert_same(expected, actual, message="")
|
43
|
+
# 若actual.equal?(expected) 为真则 pass
|
44
|
+
#
|
45
|
+
# assert_not_same(expected, actual, message="")
|
46
|
+
# 若!actual.equal?(expected) 为真则 pass
|
47
|
+
#
|
48
|
+
# assert_operator(object1, operator, object2, message="")
|
49
|
+
# 若object1.send(operator, object2) 为真则 pass
|
50
|
+
#
|
51
|
+
# assert_raises(expected_exception_klass, message="") { ... }
|
52
|
+
# 执行块的内容引发异常, 若该异常属于expected_exception_klass类则pass
|
53
|
+
#
|
54
|
+
# assert_nothing_raised(*args) { ... }
|
55
|
+
# 执行块的内容, 若没有引发异常则pass
|
56
|
+
#
|
57
|
+
# flunk(message="")
|
58
|
+
# 通常会失败
|
59
|
+
#
|
60
|
+
# assert_throws(expected_symbol, message="") { ... }
|
61
|
+
# 执行块的内容,若:expected_symbol被throw了,则pass
|
62
|
+
#
|
63
|
+
# assert_nothing_thrown(message="") { ... }
|
64
|
+
# 执行块的内容, 若没有发生throw则pass
|
65
|
+
#
|
66
|
+
# assert_in_delta(expected_float, actual_float, delta, message="")
|
67
|
+
# 若(expected_float.to_f - actual_float.to_f).abs <= delta.to_f 为真则 pass
|
68
|
+
#
|
69
|
+
# delta必须是正数。
|
70
|
+
#
|
71
|
+
# assert_send(send_array, message="")
|
72
|
+
# 若send_array[0].__send__(send_array[1], *send_array[2..-1])为真则 pass
|
73
|
+
#
|
74
|
+
# assert_block(message="") { ... }
|
75
|
+
# 若block的结果为真则 pass
|
76
|
+
|
77
|
+
class MdpreviewTest < Test::Unit::TestCase
|
78
|
+
# include Mdpreview
|
79
|
+
|
80
|
+
def setup
|
81
|
+
@friends = ['dell', 'apple', 'sony']
|
82
|
+
end
|
83
|
+
|
84
|
+
def teardown
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_add
|
88
|
+
# Mdpreview.hi "sss"
|
89
|
+
|
90
|
+
|
91
|
+
assert_instance_of(Array, @friends, "The @friends must be Array")
|
92
|
+
|
93
|
+
assert_equal(3, @friends.size, "The size is not 3")
|
94
|
+
|
95
|
+
@friends << 'acer'
|
96
|
+
assert_equal(4, @friends.size, "The size is not 4")
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
end
|
data/vendor/cur.file
ADDED
data/vendor/meta.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/Volumes/data/Github/toc.md/README.md
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
|
2
|
+
margin: 0;padding: 0;border: 0;outline: 0;font-weight: inherit;font-style: inherit;font-size: 100%;font-family: inherit;vertical-align: baseline;}
|
3
|
+
body {color: #2f332a;font: 15px/21px Arial, Helvetica, simsun, sans-serif;background: #f0f6e4 \9;}
|
4
|
+
h1, h2, h3, h4, h5, h6 {color: #2f332a;font-weight: bold;font-family: Helvetica, Arial, sans-serif;padding-bottom: 5px;}
|
5
|
+
h1 {font-size: 24px;line-height: 34px;text-align: center;}
|
6
|
+
h2 {font-size: 14px;line-height: 24px;padding-top: 5px;}
|
7
|
+
h6 {font-weight: normal;font-size: 12px;letter-spacing: 1px;line-height: 24px;text-align: center;}
|
8
|
+
a {color:#3C6E31;text-decoration: underline;}
|
9
|
+
a:hover {background-color:#3C6E31;color:white;}
|
10
|
+
input.radio {margin: 0 2px 0 8px;}
|
11
|
+
input.radio.first {margin-left:0;}
|
12
|
+
input.empty {color: lightgray;}
|
13
|
+
code {color: #2f332a;}
|
14
|
+
.highlight_red {color:#A60000;}
|
15
|
+
.highlight_green {color:#A7F43D;}
|
16
|
+
li {list-style: circle;font-size: 12px;}
|
17
|
+
li.title {list-style: none;}
|
18
|
+
ul.list {margin-left: 17px;}
|
19
|
+
|
20
|
+
div.content_wrap {width: 600px;height:380px;}
|
21
|
+
div.content_wrap div.left{float: left;width: 250px;}
|
22
|
+
div.content_wrap div.right{float: right;width: 340px;}
|
23
|
+
div.zTreeDemoBackground {width:250px;height:362px;text-align:left;}
|
24
|
+
|
25
|
+
ul.ztree {margin-top: 10px;border: 1px solid #617775;background: #f0f6e4;width:220px;height:360px;overflow-y:scroll;overflow-x:auto;}
|
26
|
+
ul.log {border: 1px solid #617775;background: #f0f6e4;width:300px;height:170px;overflow: hidden;}
|
27
|
+
ul.log.small {height:45px;}
|
28
|
+
ul.log li {color: #666666;list-style: none;padding-left: 10px;}
|
29
|
+
ul.log li.dark {background-color: #E3E3E3;}
|
30
|
+
|
31
|
+
/* ruler */
|
32
|
+
div.ruler {height:20px; width:220px; background-color:#f0f6e4;border: 1px solid #333; margin-bottom: 5px; cursor: pointer}
|
33
|
+
div.ruler div.cursor {height:20px; width:30px; background-color:#3C6E31; color:white; text-align: right; padding-right: 5px; cursor: pointer}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,97 @@
|
|
1
|
+
/*-------------------------------------
|
2
|
+
zTree Style
|
3
|
+
|
4
|
+
version: 3.4
|
5
|
+
author: Hunter.z
|
6
|
+
email: hunter.z@263.net
|
7
|
+
website: http://code.google.com/p/jquerytree/
|
8
|
+
|
9
|
+
-------------------------------------*/
|
10
|
+
|
11
|
+
.ztree * {padding:0; margin:0; font-size:12px; font-family: Verdana, Arial, Helvetica, AppleGothic, sans-serif}
|
12
|
+
.ztree {margin:0; padding:5px; color:#333}
|
13
|
+
.ztree li{padding:0; margin:0; list-style:none; line-height:14px; text-align:left; white-space:nowrap; outline:0}
|
14
|
+
.ztree li ul{ margin:0; padding:0 0 0 18px}
|
15
|
+
.ztree li ul.line{ background:url(./img/line_conn.gif) 0 0 repeat-y;}
|
16
|
+
|
17
|
+
.ztree li a {padding:1px 3px 0 0; margin:0; cursor:pointer; height:17px; color:#333; background-color: transparent;
|
18
|
+
text-decoration:none; vertical-align:top; display: inline-block}
|
19
|
+
.ztree li a:hover {text-decoration:underline}
|
20
|
+
.ztree li a.curSelectedNode {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;}
|
21
|
+
.ztree li a.curSelectedNode_Edit {padding-top:0px; background-color:#FFE6B0; color:black; height:16px; border:1px #FFB951 solid; opacity:0.8;}
|
22
|
+
.ztree li a.tmpTargetNode_inner {padding-top:0px; background-color:#316AC5; color:white; height:16px; border:1px #316AC5 solid;
|
23
|
+
opacity:0.8; filter:alpha(opacity=80)}
|
24
|
+
.ztree li a.tmpTargetNode_prev {}
|
25
|
+
.ztree li a.tmpTargetNode_next {}
|
26
|
+
.ztree li a input.rename {height:14px; width:80px; padding:0; margin:0;
|
27
|
+
font-size:12px; border:1px #7EC4CC solid; *border:0px}
|
28
|
+
.ztree li span {line-height:16px; margin-right:2px}
|
29
|
+
.ztree li span.button {line-height:0; margin:0; width:16px; height:16px; display: inline-block; vertical-align:middle;
|
30
|
+
border:0 none; cursor: pointer;outline:none;
|
31
|
+
background-color:transparent; background-repeat:no-repeat; background-attachment: scroll;
|
32
|
+
background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")}
|
33
|
+
|
34
|
+
.ztree li span.button.chk {width:13px; height:13px; margin:0 3px 0 0; cursor: auto}
|
35
|
+
.ztree li span.button.chk.checkbox_false_full {background-position:0 0}
|
36
|
+
.ztree li span.button.chk.checkbox_false_full_focus {background-position:0 -14px}
|
37
|
+
.ztree li span.button.chk.checkbox_false_part {background-position:0 -28px}
|
38
|
+
.ztree li span.button.chk.checkbox_false_part_focus {background-position:0 -42px}
|
39
|
+
.ztree li span.button.chk.checkbox_false_disable {background-position:0 -56px}
|
40
|
+
.ztree li span.button.chk.checkbox_true_full {background-position:-14px 0}
|
41
|
+
.ztree li span.button.chk.checkbox_true_full_focus {background-position:-14px -14px}
|
42
|
+
.ztree li span.button.chk.checkbox_true_part {background-position:-14px -28px}
|
43
|
+
.ztree li span.button.chk.checkbox_true_part_focus {background-position:-14px -42px}
|
44
|
+
.ztree li span.button.chk.checkbox_true_disable {background-position:-14px -56px}
|
45
|
+
.ztree li span.button.chk.radio_false_full {background-position:-28px 0}
|
46
|
+
.ztree li span.button.chk.radio_false_full_focus {background-position:-28px -14px}
|
47
|
+
.ztree li span.button.chk.radio_false_part {background-position:-28px -28px}
|
48
|
+
.ztree li span.button.chk.radio_false_part_focus {background-position:-28px -42px}
|
49
|
+
.ztree li span.button.chk.radio_false_disable {background-position:-28px -56px}
|
50
|
+
.ztree li span.button.chk.radio_true_full {background-position:-42px 0}
|
51
|
+
.ztree li span.button.chk.radio_true_full_focus {background-position:-42px -14px}
|
52
|
+
.ztree li span.button.chk.radio_true_part {background-position:-42px -28px}
|
53
|
+
.ztree li span.button.chk.radio_true_part_focus {background-position:-42px -42px}
|
54
|
+
.ztree li span.button.chk.radio_true_disable {background-position:-42px -56px}
|
55
|
+
|
56
|
+
.ztree li span.button.switch {width:18px; height:18px}
|
57
|
+
.ztree li span.button.root_open{background-position:-92px -54px}
|
58
|
+
.ztree li span.button.root_close{background-position:-74px -54px}
|
59
|
+
.ztree li span.button.roots_open{background-position:-92px 0}
|
60
|
+
.ztree li span.button.roots_close{background-position:-74px 0}
|
61
|
+
.ztree li span.button.center_open{background-position:-92px -18px}
|
62
|
+
.ztree li span.button.center_close{background-position:-74px -18px}
|
63
|
+
.ztree li span.button.bottom_open{background-position:-92px -36px}
|
64
|
+
.ztree li span.button.bottom_close{background-position:-74px -36px}
|
65
|
+
.ztree li span.button.noline_open{background-position:-92px -72px}
|
66
|
+
.ztree li span.button.noline_close{background-position:-74px -72px}
|
67
|
+
.ztree li span.button.root_docu{ background:none;}
|
68
|
+
.ztree li span.button.roots_docu{background-position:-56px 0}
|
69
|
+
.ztree li span.button.center_docu{background-position:-56px -18px}
|
70
|
+
.ztree li span.button.bottom_docu{background-position:-56px -36px}
|
71
|
+
.ztree li span.button.noline_docu{ background:none;}
|
72
|
+
|
73
|
+
.ztree li span.button.ico_open{margin-right:2px; background-position:-110px -16px; vertical-align:top; *vertical-align:middle}
|
74
|
+
.ztree li span.button.ico_close{margin-right:2px; background-position:-110px 0; vertical-align:top; *vertical-align:middle}
|
75
|
+
.ztree li span.button.ico_docu{margin-right:2px; background-position:-110px -32px; vertical-align:top; *vertical-align:middle}
|
76
|
+
.ztree li span.button.edit {margin-right:2px; background-position:-110px -48px; vertical-align:top; *vertical-align:middle}
|
77
|
+
.ztree li span.button.remove {margin-right:2px; background-position:-110px -64px; vertical-align:top; *vertical-align:middle}
|
78
|
+
|
79
|
+
.ztree li span.button.ico_loading{margin-right:2px; background:url(./img/loading.gif) no-repeat scroll 0 0 transparent; vertical-align:top; *vertical-align:middle}
|
80
|
+
|
81
|
+
ul.tmpTargetzTree {background-color:#FFE6B0; opacity:0.8; filter:alpha(opacity=80)}
|
82
|
+
|
83
|
+
span.tmpzTreeMove_arrow {width:16px; height:16px; display: inline-block; padding:0; margin:2px 0 0 1px; border:0 none; position:absolute;
|
84
|
+
background-color:transparent; background-repeat:no-repeat; background-attachment: scroll;
|
85
|
+
background-position:-110px -80px; background-image:url("./img/zTreeStandard.png"); *background-image:url("./img/zTreeStandard.gif")}
|
86
|
+
|
87
|
+
ul.ztree.zTreeDragUL {margin:0; padding:0; position:absolute; width:auto; height:auto;overflow:hidden; background-color:#cfcfcf; border:1px #00B83F dotted; opacity:0.8; filter:alpha(opacity=80)}
|
88
|
+
.zTreeMask {z-index:10000; background-color:#cfcfcf; opacity:0.0; filter:alpha(opacity=0); position:absolute}
|
89
|
+
|
90
|
+
/* level style*/
|
91
|
+
/*.ztree li span.button.level0 {
|
92
|
+
display:none;
|
93
|
+
}
|
94
|
+
.ztree li ul.level0 {
|
95
|
+
padding:0;
|
96
|
+
background:none;
|
97
|
+
}*/
|