Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
This commit is contained in:
commit
47e76794cd
|
@ -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,21 +38,23 @@ 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)
|
|
||||||
|
# Switch to ruby 1.9 String#encode
|
||||||
# puts "Data: #{data.inspect}: #{data}"
|
# with backward 1.8 compatibility
|
||||||
# puts "Conv: #{converted.inspect}: #{converted}"
|
if data.respond_to?(:encode!)
|
||||||
|
data.encode!('UTF-8', enc)
|
||||||
data = converted
|
else
|
||||||
|
require 'iconv'
|
||||||
|
data = Iconv.new('utf-8', enc).iconv(data)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@children = parse_text_as_markdown(data)
|
@children = parse_text_as_markdown(data)
|
||||||
|
|
||||||
if true #markdown_extra?
|
if true #markdown_extra?
|
||||||
|
|
Loading…
Reference in a new issue