Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion html2confluence.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'html2confluence'
s.version = "1.3.8"
s.version = "1.3.9"
s.summary = 'Converter from HTML to Confluence Wiki Markup'
s.description = 'Provides an SGML parser to convert HTML into the Wiki Markup format'

Expand All @@ -13,4 +13,6 @@ Gem::Specification.new do |s|

s.require_path = 'lib'
s.files = Dir.glob("{lib,spec}/**/*") + %w(example.rb README.mdown)

s.add_dependency "nokogiri"
end
10 changes: 10 additions & 0 deletions lib/html2confluence.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require 'rexml/document'

require 'nokogiri' # For validating html from our editor

# A class to convert HTML to textile. Based on the python parser
# found at http://aftnn.org/content/code/html2textile/
#
Expand Down Expand Up @@ -406,6 +408,14 @@ def preprocess(data)

# Fix unclosed <img>
data.gsub!(/(<img[^>]+)(?<!\/)>/, '\1 />')

# Parse with nokogiri to ensure not tags are left unclosed
# Ensure a parsing error from Nokogiri can't stop processing to get better error from REXML
begin
validated_data = Nokogiri::HTML::fragment(data).to_xml
data = validated_data
rescue Exception => e
end

data
end
Expand Down