lib/storys/story.rb in storys-0.0.5 vs lib/storys/story.rb in storys-0.0.6
- old
+ new
@@ -47,17 +47,15 @@
end
def update_manifest
manifest_path = package.pathname_to_url(package.app_path + "manifest", path.dirname)
new_html = html.sub(/<html.*?>/, "<html manifest=\"#{manifest_path}\">")
- File.open(path, "w") { |f| f << new_html }
+ path.write(new_html, preserve_mtime: true)
end
- private
-
def title_from_html
html =~ /<title>(.*?)<\/title>/m
- $1 ? CGI::unescapeHTML($1) : ""
+ $1 ? CGI::unescapeHTML($1.gsub(/\s+/, " ").strip) : ""
end
def word_count_from_html
html =~ /<body.*?>(.*?)<\/body>/m
body = CGI::unescapeHTML($1.gsub(/<\/?(p|b|i|h[1234567]).*?>/m, " "))