wunderbar 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,9 +99,29 @@ module Wunderbar
99
99
  end
100
100
 
101
101
  class XmlMarkup < BuilderClass
102
- def initialize(args)
102
+ # convenience method for taking an XML node or string and formatting it
103
+ def self.dump(content, args={})
104
+ markup = self.new(args)
105
+
106
+ if Nokogiri::XML::Document === content and content.root.name == 'html'
107
+ markup.declare! :DOCTYPE, :html
108
+ end
109
+
110
+ unless Nokogiri::XML::Node === content
111
+ if defined? Nokogiri::HTML5.fragment
112
+ content = Nokogiri::HTML5.fragment(content.to_s)
113
+ else
114
+ content = Nokogiri::HTML.fragment(content.to_s)
115
+ end
116
+ end
117
+
118
+ markup[content]
119
+ markup.target!
120
+ end
121
+
122
+ def initialize(args={})
103
123
  @_scope = args.delete(:scope)
104
- @_indent = args.delete(:indent) or 2
124
+ @_indent = args.delete(:indent) || 2
105
125
  @_pdf = false
106
126
  @doc = Node.new(nil)
107
127
  @node = @doc
@@ -259,6 +279,7 @@ module Wunderbar
259
279
  def <<(data)
260
280
  if defined? Nokogiri
261
281
  if not String === data or data.include? '<' or data.include? '&'
282
+ # https://github.com/google/gumbo-parser/issues/266
262
283
  data = Nokogiri::HTML::fragment(data.to_s).to_xml
263
284
 
264
285
  # fix CDATA in most cases (notably scripts)
@@ -289,8 +310,14 @@ module Wunderbar
289
310
  end
290
311
 
291
312
  def [](*children)
292
- if children.length == 1 and children.first.respond_to? :root
293
- children = [children.first.root]
313
+ if children.length == 1
314
+ if children.first.respond_to? :root
315
+ children = [children.first.root]
316
+ elsif defined? Nokogiri::XML::DocumentFragment and
317
+ Nokogiri::XML::DocumentFragment === children.first
318
+ then
319
+ children = children.first.children
320
+ end
294
321
  end
295
322
 
296
323
  # remove leading and trailing space
@@ -341,7 +341,7 @@ module Wunderbar
341
341
  return @_x
342
342
  end
343
343
 
344
- children = block.call
344
+ children = instance_eval &block
345
345
 
346
346
  if String === children
347
347
  safe = !children.tainted?
@@ -382,6 +382,8 @@ module Wunderbar
382
382
  else
383
383
  return @_x.indented_text! children
384
384
  end
385
+ elsif children.nil? or Wunderbar::Node === children
386
+ return children
385
387
  end
386
388
 
387
389
  @_x[*children]
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 22
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.22.0"
5
+ s.version = "0.22.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Ruby"]
9
- s.date = "2014-12-23"
9
+ s.date = "2015-01-02"
10
10
  s.description = " Wunderbar makes it easy to produce valid HTML5, wellformed XHTML, Unicode\n (utf-8), consistently indented, readable applications. This includes\n output that conforms to the Polyglot specification and the emerging\n results from the XML Error Recovery Community Group.\n"
11
11
  s.email = "rubys@intertwingly.net"
12
12
  s.files = ["wunderbar.gemspec", "README.md", "COPYING", "lib/wunderbar.rb", "lib/wunderbar", "lib/wunderbar/script.rb", "lib/wunderbar/jquery.rb", "lib/wunderbar/underscore.rb", "lib/wunderbar/polymer.rb", "lib/wunderbar/jquery", "lib/wunderbar/jquery/filter.rb", "lib/wunderbar/jquery/stupidtable.rb", "lib/wunderbar/vendor", "lib/wunderbar/vendor/polymer-v0.0.20131003.min.js", "lib/wunderbar/vendor/stupidtable.min.js", "lib/wunderbar/vendor/bootstrap.min.js", "lib/wunderbar/vendor/Markdown.Converter.js", "lib/wunderbar/vendor/angular.min.js", "lib/wunderbar/vendor/bootstrap-theme.min.css", "lib/wunderbar/vendor/jquery-1.11.0.min.js", "lib/wunderbar/vendor/angular-resource.min.js", "lib/wunderbar/vendor/bootstrap.min.css", "lib/wunderbar/vendor/underscore-min.js", "lib/wunderbar/vendor/angular-route.min.js", "lib/wunderbar/websocket.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/pagedown.rb", "lib/wunderbar/version.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/server.rb", "lib/wunderbar/angularjs.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/asset.rb", "lib/wunderbar/backtick.rb", "lib/wunderbar/opal", "lib/wunderbar/opal/browser.rb", "lib/wunderbar/opal/jquery.rb", "lib/wunderbar/coffeescript.rb", "lib/wunderbar/markdown.rb", "lib/wunderbar/opal.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/bootstrap.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/sinatra.rb", "lib/wunderbar/rails.rb", "lib/wunderbar/angularjs", "lib/wunderbar/angularjs/resource.rb", "lib/wunderbar/angularjs/route.rb", "lib/wunderbar/rack.rb", "lib/wunderbar/coderay.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/bootstrap", "lib/wunderbar/bootstrap/theme.rb", "lib/wunderbar/cssproxy.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/node.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.22.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-23 00:00:00.000000000 Z
12
+ date: 2015-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json