docwu 0.0.12 → 0.0.13
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/lib/docwu/render.rb +0 -11
- data/lib/docwu/utils.rb +23 -25
- data/lib/docwu/version.rb +1 -1
- data/lib/template_files/Gemfile +1 -1
- metadata +3 -4
- data/lib/template_files/static/_static.html +0 -0
data/lib/docwu/render.rb
CHANGED
@@ -41,17 +41,6 @@ module Docwu
|
|
41
41
|
|
42
42
|
_html = ::RedcarpetCompat.new(content_text, *_mark_options).to_html
|
43
43
|
|
44
|
-
# renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
|
45
|
-
# :tables => true,
|
46
|
-
# :hard_wrap => true,
|
47
|
-
# :autolink => true,
|
48
|
-
# :no_intraemphasis => true,
|
49
|
-
# :fenced_code => true,
|
50
|
-
# :gh_blockcode => true
|
51
|
-
# })
|
52
|
-
|
53
|
-
# _html = renderer.render(content_text)
|
54
|
-
|
55
44
|
# 获取一个html代码的目录结果
|
56
45
|
_catalogs_result = ::Docwu::Utils.html_catalogable(_html)
|
57
46
|
|
data/lib/docwu/utils.rb
CHANGED
@@ -82,39 +82,36 @@ module Docwu
|
|
82
82
|
doc = ::Nokogiri::HTML(html)
|
83
83
|
|
84
84
|
doc.search("//pre").each do |pre|
|
85
|
-
|
85
|
+
begin
|
86
|
+
lang = pre.attr('lang')
|
86
87
|
|
87
|
-
|
88
|
-
|
88
|
+
if lang
|
89
|
+
_lang_class = pre.attr('class').to_s.split(' ').select {|_itm| _itm.include?('lang-') }.first
|
89
90
|
|
90
|
-
|
91
|
-
|
91
|
+
if _lang_class
|
92
|
+
lang = _lang_class.gsub('lang-', '')
|
93
|
+
end
|
92
94
|
end
|
93
|
-
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
# end
|
102
|
-
|
103
|
-
if pre_code=pre.css('code')
|
104
|
-
lang = pre_code.attr('class').to_s
|
105
|
-
end
|
96
|
+
# begin
|
97
|
+
# if pre_code=pre.css('code')
|
98
|
+
# lang = pre_code.attr('class').to_s
|
99
|
+
# end
|
100
|
+
# rescue
|
101
|
+
# end
|
106
102
|
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
if pre_code=pre.css('code')
|
104
|
+
lang = pre_code.attr('class').to_s
|
105
|
+
end
|
110
106
|
|
111
|
-
|
107
|
+
if lang.to_s.strip.size > 0
|
108
|
+
text = pre.text.rstrip
|
112
109
|
|
113
|
-
|
114
|
-
|
110
|
+
# http://coderay.rubychan.de/
|
111
|
+
pre.replace ::CodeRay.scan(text, lang).div.to_s
|
112
|
+
end
|
115
113
|
rescue Exception => error
|
116
|
-
# TODO: error log
|
117
|
-
# puts "#{__FILE__} syntax_highlighter error: \ntext => #{text} \nlang => #{lang}\n origin error:#{error}"
|
114
|
+
# TODO: Add error log here
|
118
115
|
end
|
119
116
|
end
|
120
117
|
|
@@ -193,6 +190,7 @@ module Docwu
|
|
193
190
|
'catalogs' => catalogs,
|
194
191
|
'html' => doc.css('body').inner_html.to_s
|
195
192
|
}
|
193
|
+
|
196
194
|
end
|
197
195
|
end
|
198
196
|
|
data/lib/docwu/version.rb
CHANGED
data/lib/template_files/Gemfile
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docwu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -120,7 +120,6 @@ files:
|
|
120
120
|
- lib/template_files/topics/index.markdown
|
121
121
|
- lib/template_files/doc/help/README.md
|
122
122
|
- lib/template_files/config.yml
|
123
|
-
- lib/template_files/static/_static.html
|
124
123
|
- lib/template_files/Gemfile
|
125
124
|
- lib/template_files/assets/images/shared/folder/README.txt
|
126
125
|
- lib/template_files/assets/images/shared/folder/user.png
|
@@ -155,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
154
|
version: '0'
|
156
155
|
segments:
|
157
156
|
- 0
|
158
|
-
hash:
|
157
|
+
hash: -2852319421146179555
|
159
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
159
|
none: false
|
161
160
|
requirements:
|
@@ -164,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
163
|
version: '0'
|
165
164
|
segments:
|
166
165
|
- 0
|
167
|
-
hash:
|
166
|
+
hash: -2852319421146179555
|
168
167
|
requirements: []
|
169
168
|
rubyforge_project:
|
170
169
|
rubygems_version: 1.8.25
|
File without changes
|