Sha256: 2dc5dbb75cfacbcfdb17ac7ea0aa0850f46d309dfd534d64586859642f8c0ddb
Contents?: true
Size: 1.58 KB
Versions: 19
Compression:
Stored size: 1.58 KB
Contents
# Global text helpers # module.exports = # Whitespace helper function. # # @param [Number] n the number if indents # @return [String] the indention string # whitespace: (n) -> n = n * 2 a = [] while a.length < n a.push ' ' a.join '' # Escape quotation in a text. # # @param [String] text the text containing quotes # @return [String] the escaped text # escapeQuotes: (text) -> return '' unless text text.replace(/"/g, '\\"').replace(/\\\\\"/g, '\\"') # Unescape quotation in a text. # # @param [String] text the text containing escaped quotes # @return [String] the text without escaped quotes # unescapeQuotes: (text) -> return '' unless text text.replace(/\\"/g, '"') # HTML Escape a text. # # @param [String] text the text # @return [String] the HTML escaped text # escapeHTML: (text) -> return '' unless text text .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/\"/g, '"') # Preserve newlines within the preserve tags, # # @param [String] code the code to preserve # @return [String] the preserved code # preserve: (code) -> if code code.replace(/\r/g, '') code.replace /<(pre|textarea)>(.*?)<\/\1>/g, (text) -> text.replace('\\n', '\&\#x000A;') # Indent the given text. # # @param [String] text the text to indent # @param [Integer] the amount of spaced to insert # @return [String] the indented text # indent: (text, spaces) -> text.replace /^(.*)$/mg, module.exports.whitespace(spaces) + '$1'
Version data entries
19 entries across 19 versions & 1 rubygems