Loading lib/jsduck/doc_formatter.rb +4 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ require 'rdiscount' require 'jsduck/logger' require 'jsduck/inline/img' require 'jsduck/inline/video' require 'jsduck/html' require 'jsduck/util/html' module JsDuck Loading Loading @@ -274,7 +274,7 @@ module JsDuck when '%-' member ? "-" : "" when '%a' HTML.escape(anchor_text||"") Util::HTML.escape(anchor_text||"") else $1 end Loading Loading @@ -327,7 +327,7 @@ module JsDuck # Blah blah blah some text. # def shorten(input) sent = first_sentence(HTML.strip_tags(input).strip) sent = first_sentence(Util::HTML.strip_tags(input).strip) # Use u-modifier to correctly count multi-byte characters chars = sent.scan(/./mu) if chars.length > @max_length Loading @@ -343,7 +343,7 @@ module JsDuck # Returns true when input should get shortened. def too_long?(input) stripped = HTML.strip_tags(input).strip stripped = Util::HTML.strip_tags(input).strip # for sentence v/s full - compare byte length # for full v/s max - compare char length first_sentence(stripped).length < stripped.length || stripped.scan(/./mu).length > @max_length Loading lib/jsduck/guides.rb +2 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ require 'jsduck/io' require 'jsduck/null_object' require 'jsduck/logger' require 'jsduck/grouped_asset' require 'jsduck/html' require 'jsduck/util/html' require 'fileutils' module JsDuck Loading Loading @@ -117,7 +117,7 @@ module JsDuck html.each_line do |line| if line =~ /^<h2>(.*)<\/h2>$/ i += 1 text = HTML.strip_tags($1) text = Util::HTML.strip_tags($1) toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{text}</a></li>\n" new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{text}</h2>\n" else Loading lib/jsduck/html.rbdeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line require 'cgi' module JsDuck # Helpers for dealing with HTML class HTML # Strips tags from HTML text def self.strip_tags(html) html.gsub(/<.*?>/, "") end # Escapes HTML, replacing < with < ... def self.escape(html) CGI.escapeHTML(html) end # Unescapes HTML, replacing < with < ... def self.unescape(html) CGI.unescapeHTML(html) end end end lib/jsduck/inline/img.rb +2 −2 Original line number Diff line number Diff line require 'jsduck/html' require 'jsduck/util/html' require 'jsduck/logger' module JsDuck Loading Loading @@ -43,7 +43,7 @@ module JsDuck when '%u' @base_path ? (@base_path + "/" + url) : url when '%a' HTML.escape(alt_text||"") Util::HTML.escape(alt_text||"") else $1 end Loading lib/jsduck/inline/video.rb +2 −2 Original line number Diff line number Diff line require 'jsduck/html' require 'jsduck/util/html' require 'jsduck/logger' module JsDuck Loading Loading @@ -48,7 +48,7 @@ module JsDuck when '%u' url when '%a' HTML.escape(alt_text||"") Util::HTML.escape(alt_text||"") else $1 end Loading Loading
lib/jsduck/doc_formatter.rb +4 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ require 'rdiscount' require 'jsduck/logger' require 'jsduck/inline/img' require 'jsduck/inline/video' require 'jsduck/html' require 'jsduck/util/html' module JsDuck Loading Loading @@ -274,7 +274,7 @@ module JsDuck when '%-' member ? "-" : "" when '%a' HTML.escape(anchor_text||"") Util::HTML.escape(anchor_text||"") else $1 end Loading Loading @@ -327,7 +327,7 @@ module JsDuck # Blah blah blah some text. # def shorten(input) sent = first_sentence(HTML.strip_tags(input).strip) sent = first_sentence(Util::HTML.strip_tags(input).strip) # Use u-modifier to correctly count multi-byte characters chars = sent.scan(/./mu) if chars.length > @max_length Loading @@ -343,7 +343,7 @@ module JsDuck # Returns true when input should get shortened. def too_long?(input) stripped = HTML.strip_tags(input).strip stripped = Util::HTML.strip_tags(input).strip # for sentence v/s full - compare byte length # for full v/s max - compare char length first_sentence(stripped).length < stripped.length || stripped.scan(/./mu).length > @max_length Loading
lib/jsduck/guides.rb +2 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ require 'jsduck/io' require 'jsduck/null_object' require 'jsduck/logger' require 'jsduck/grouped_asset' require 'jsduck/html' require 'jsduck/util/html' require 'fileutils' module JsDuck Loading Loading @@ -117,7 +117,7 @@ module JsDuck html.each_line do |line| if line =~ /^<h2>(.*)<\/h2>$/ i += 1 text = HTML.strip_tags($1) text = Util::HTML.strip_tags($1) toc << "<li><a href='#!/guide/#{guide['name']}-section-#{i}'>#{text}</a></li>\n" new_html << "<h2 id='#{guide['name']}-section-#{i}'>#{text}</h2>\n" else Loading
lib/jsduck/html.rbdeleted 100644 → 0 +0 −25 Original line number Diff line number Diff line require 'cgi' module JsDuck # Helpers for dealing with HTML class HTML # Strips tags from HTML text def self.strip_tags(html) html.gsub(/<.*?>/, "") end # Escapes HTML, replacing < with < ... def self.escape(html) CGI.escapeHTML(html) end # Unescapes HTML, replacing < with < ... def self.unescape(html) CGI.unescapeHTML(html) end end end
lib/jsduck/inline/img.rb +2 −2 Original line number Diff line number Diff line require 'jsduck/html' require 'jsduck/util/html' require 'jsduck/logger' module JsDuck Loading Loading @@ -43,7 +43,7 @@ module JsDuck when '%u' @base_path ? (@base_path + "/" + url) : url when '%a' HTML.escape(alt_text||"") Util::HTML.escape(alt_text||"") else $1 end Loading
lib/jsduck/inline/video.rb +2 −2 Original line number Diff line number Diff line require 'jsduck/html' require 'jsduck/util/html' require 'jsduck/logger' module JsDuck Loading Loading @@ -48,7 +48,7 @@ module JsDuck when '%u' url when '%a' HTML.escape(alt_text||"") Util::HTML.escape(alt_text||"") else $1 end Loading