From e3d119b851b033f7b686c5f1136671b79dd29b74 Mon Sep 17 00:00:00 2001 From: Egor Dovnar Date: Sat, 28 Dec 2024 04:31:59 +0300 Subject: [PATCH] Make the `result` not frozen since it's going to be modified; fix the url opening with open-uri --- lib/html2markdown/converter.rb | 2 +- lib/html2markdown/html_page.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/html2markdown/converter.rb b/lib/html2markdown/converter.rb index 2bb23c9..90c6fd7 100644 --- a/lib/html2markdown/converter.rb +++ b/lib/html2markdown/converter.rb @@ -27,7 +27,7 @@ def parse_element(ele) # wrap node with markdown def wrap_node(node,contents=nil) - result = '' + result = ''.dup contents.strip! unless contents==nil # check if there is a custom parse exist if respond_to? "parse_#{node.name}" diff --git a/lib/html2markdown/html_page.rb b/lib/html2markdown/html_page.rb index afb2062..ad9977e 100644 --- a/lib/html2markdown/html_page.rb +++ b/lib/html2markdown/html_page.rb @@ -9,7 +9,7 @@ def initialize(options,&content_extrator) @host = options[:host] @url = options[:url] if (@contents = options[:contents]) == nil - doc = Nokogiri::HTML(open(@url)) + doc = Nokogiri::HTML(URI.open(@url)) @contents = doc.at_css('body').send(:inner_html) || doc.inner_html end @content_extrator = content_extrator