Update Maruku
This commit is contained in:
parent
b52a66c207
commit
40fd643680
|
@ -18,8 +18,6 @@
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#++
|
#++
|
||||||
|
|
||||||
|
|
||||||
require 'iconv'
|
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
require 'strscan'
|
require 'strscan'
|
||||||
|
|
||||||
|
@ -40,19 +38,21 @@ Summary: Encoding for the document.
|
||||||
|
|
||||||
If the `encoding` attribute is specified, then the content
|
If the `encoding` attribute is specified, then the content
|
||||||
will be converted from the specified encoding to UTF-8.
|
will be converted from the specified encoding to UTF-8.
|
||||||
|
|
||||||
Conversion happens using the `iconv` library.
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
enc = self.attributes[:encoding]
|
enc = self.attributes[:encoding]
|
||||||
self.attributes.delete :encoding
|
self.attributes.delete :encoding
|
||||||
if enc && enc.downcase != 'utf-8'
|
if enc && enc.downcase != 'utf-8'
|
||||||
converted = Iconv.new('utf-8', enc).iconv(data)
|
|
||||||
|
|
||||||
# puts "Data: #{data.inspect}: #{data}"
|
# Switch to ruby 1.9 String#encode
|
||||||
# puts "Conv: #{converted.inspect}: #{converted}"
|
# with backward 1.8 compatibility
|
||||||
|
if data.respond_to?(:encode!)
|
||||||
|
data.encode!('UTF-8', enc)
|
||||||
|
else
|
||||||
|
require 'iconv'
|
||||||
|
data = Iconv.new('utf-8', enc).iconv(data)
|
||||||
|
end
|
||||||
|
|
||||||
data = converted
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@children = parse_text_as_markdown(data)
|
@children = parse_text_as_markdown(data)
|
||||||
|
|
Loading…
Reference in a new issue