docwu 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
 
@@ -82,39 +82,36 @@ module Docwu
82
82
  doc = ::Nokogiri::HTML(html)
83
83
 
84
84
  doc.search("//pre").each do |pre|
85
- lang = pre.attr('lang')
85
+ begin
86
+ lang = pre.attr('lang')
86
87
 
87
- if lang
88
- _lang_class = pre.attr('class').to_s.split(' ').select {|_itm| _itm.include?('lang-') }.first
88
+ if lang
89
+ _lang_class = pre.attr('class').to_s.split(' ').select {|_itm| _itm.include?('lang-') }.first
89
90
 
90
- if _lang_class
91
- lang = _lang_class.gsub('lang-', '')
91
+ if _lang_class
92
+ lang = _lang_class.gsub('lang-', '')
93
+ end
92
94
  end
93
- end
94
95
 
95
- # debugger
96
- # begin
97
- # if pre_code=pre.css('code')
98
- # lang = pre_code.attr('class').to_s
99
- # end
100
- # rescue
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
- unless lang
108
- lang = :text
109
- end
103
+ if pre_code=pre.css('code')
104
+ lang = pre_code.attr('class').to_s
105
+ end
110
106
 
111
- text = pre.text.rstrip
107
+ if lang.to_s.strip.size > 0
108
+ text = pre.text.rstrip
112
109
 
113
- begin
114
- pre.replace ::CodeRay.scan(text, lang).div.to_s
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
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Docwu
3
- VERSION = "0.0.12"
3
+ VERSION = "0.0.13"
4
4
  end
@@ -1,3 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'docwu', '0.0.12'
3
+ gem 'docwu', '0.0.13'
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.12
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: 99893025008064787
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: 99893025008064787
166
+ hash: -2852319421146179555
168
167
  requirements: []
169
168
  rubyforge_project:
170
169
  rubygems_version: 1.8.25
File without changes