wraptext 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,13 +6,10 @@ module Wraptext
6
6
  figure figcaption details menu summary h1 h2 h3 h4 h5 h6 script"
7
7
  BLOCK_TAGS_LOOKUP = Hash[*BLOCK_TAGS.map {|e| [e, 1]}.flatten]
8
8
 
9
- NO_WRAP_TAG = %w"table thead tfoot caption col colgroup tbody tr td th dl dd dt
10
- ul ol li pre select option form map area math style input hr
11
- fieldset legend section article aside hgroup header footer nav
12
- figure figcaption details menu summary h1 h2 h3 h4 h5 h6 script"
13
- NO_WRAP_TAG_LOOKUP = Hash[*NO_WRAP_TAG.map {|e| [e, 1]}.flatten]
9
+ NO_WRAP_IN = %w"h1 h2 h3 h4 h5 h6"
10
+ NO_WRAP_IN_LOOKUP = Hash[*NO_WRAP_IN.map {|e| [e, 1]}.flatten]
14
11
 
15
- STRAIGHT_COPY_TAGS = %w"script pre textarea"
12
+ STRAIGHT_COPY_TAGS = %w"script pre textarea style"
16
13
  STRAIGHT_COPY_TAGS_LOOKUP = Hash[*STRAIGHT_COPY_TAGS.map {|e| [e, 1]}.flatten]
17
14
  MULTIPLE_NEWLINES_REGEX = /(\r\n|\n){2,}/
18
15
 
@@ -47,9 +44,9 @@ module Wraptext
47
44
  @root.xpath("//p").each do |n|
48
45
  if n.inner_html.strip == ''
49
46
  n.remove
50
- elsif n.content.strip == ''
51
- n.parent.add_child n.children
52
- n.remove
47
+ #elsif n.content.strip == ''
48
+ # n.parent.add_child n.children
49
+ # n.remove
53
50
  end
54
51
  end
55
52
  end
@@ -67,7 +64,7 @@ module Wraptext
67
64
  # If we hit a block-level tag, we need to unwind any <p> tags we've inserted; block level elements are
68
65
  # siblings to <p> tags, not children.
69
66
  top = top.parent while top.name == "p"
70
-
67
+
71
68
  # Some tags we don't want to traverse into, like <pre> and <script>. Just copy them into the doc.
72
69
  if STRAIGHT_COPY_TAGS_LOOKUP.has_key? node.name
73
70
  top.add_child node.clone
@@ -76,7 +73,9 @@ module Wraptext
76
73
  # then recurse over the original node's children to populate it.
77
74
  copy = @root.create_element node.name, node.attributes
78
75
  top.add_child copy
76
+ @in_paragraph = true if node.name == "p"
79
77
  reparent_nodes copy, node
78
+ @in_paragraph = false if node.name == "p"
80
79
  end
81
80
 
82
81
  # If this is a text node, we need to make sure it gets wrapped in a P, unless it's in an element that
@@ -85,16 +84,28 @@ module Wraptext
85
84
  # in a <p> tag, the existing tag is re-used for the first chunk.
86
85
  elsif node.text?
87
86
  node.content.split(MULTIPLE_NEWLINES_REGEX).each_with_index do |text, index|
88
- if (index == 0 and top.name == "p") or NO_WRAP_TAG_LOOKUP.has_key?(top.name)
87
+ if NO_WRAP_IN_LOOKUP.has_key?(top.name)
89
88
  top.add_child @root.create_text_node(text)
90
- elsif top.name == "p"
91
- p = @root.create_element "p", text
92
- top.after p
93
- top = p
89
+ elsif top.children.empty?
90
+ if top.name == "p"
91
+ top.add_child @root.create_text_node(text)
92
+ else
93
+ p = @root.create_element "p", text
94
+ top.add_child p
95
+ top = p
96
+ end
94
97
  else
95
- p = @root.create_element "p", text
96
- top.add_child p
97
- top = p
98
+ if top.children.last.name == "text"
99
+ p = @root.create_element "p", text
100
+ top.after p
101
+ top = p
102
+ elsif BLOCK_TAGS_LOOKUP.has_key? top.children.last.name
103
+ p = @root.create_element "p", text
104
+ top.add_child p
105
+ top = p
106
+ else
107
+ top.add_child @root.create_text_node(text)
108
+ end
98
109
  end
99
110
  end
100
111
 
@@ -103,7 +114,7 @@ module Wraptext
103
114
  # This allows things like "<em>Foo</em> Bar Baz" to be wrapped in a single tag, as the <em> tag will be
104
115
  # wrapped in a <p> tag, then the text node will reuse the existing <p> tag when it is parsed.
105
116
  else
106
- if top.name == "p"
117
+ if top.name == "p" or NO_WRAP_IN_LOOKUP.has_key?(top.name)
107
118
  top.add_child node.clone
108
119
  else
109
120
  p = @root.create_element "p"
@@ -1,5 +1,5 @@
1
1
  <p><img src="http://mashable.com/wp-content/uploads/2010/09/mash-awards-small.jpg" class="alignleft" alt="Mashable Awards Image"><em>As part of the ongoing <a href="http://mashable.com/awards/pages/about" target="_blank">Mashable Awards</a>, we're taking a closer look at each of the <a href="http://mashable.com/awards/categories" target="_blank">nomination categories</a>. This is "<a href="http://mashable.com/awards/votes/category/49?c=49" target="_blank">Most Influential Social Good Champion</a>" supported by Yahoo!. Be sure to <a href="http://mashable.com/awards/votes" target="_blank">nominate</a> your favorites and join us for the <a href="http://mashable.com/awards/pages/event" target="-blank">Gala in Las Vegas</a>!</em></p>
2
- <p>
2
+ <p>
3
3
  <img src="http://mashable.com/wp-content/uploads/2010/11/225champ.jpg" alt="social good champion" title="225champ" width="225" height="225" class="alignright size-full wp-image-450493">Social Good is a brand new form of online giving that draws both from small non-profits and large brand cause-marketing campaigns. But like any burgeoning movement, social good requires champions to bring it to the public and promote its growth.</p>
4
4
  <p>While "social good" and "influence" may not have absolutely concrete definitions (is influence based on Twitter followers? Raising the most money?), it is easy to see when an individual has taken on the cause of social good to create some real change. </p>
5
5
  <p>Even though the exact parameters are a subjective call, we scoured the web for three social good activists who are using their skills to create change. We've highlighted three individuals who are utilizing social media and online campaigns to <a href="http://mashable.com/2010/10/09/social-media-activism/">shape the way that we think about activism</a>. </p>
@@ -22,27 +22,27 @@
22
22
  <p>When people donate money to most organizations, they're not sure what happens to their donation or how efficiently it was used. When they give to charity: water, they can <a href="http://www.charitywater.org/projects/map/" target="_blank">look up a picture and GPS coordinates</a> of the project they contributed to. Since the organization relies on private donors for the money that makes it run, there's no doubt about whether your donation ended up paying for somebody's flight instead of funding a water project. The organization even covers its PayPal fees on donations. </p>
23
23
  <p>This model of transparency and accountability has created trust and helped raise more than $20 million for 3,196 projects in the past four years. We hope that its success will influence other non-profits to do the same.</p>
24
24
  <hr>
25
- <h2>
26
- What&acirc;&euro;&trade;s Your Pick?
25
+ <h2>
26
+ What's Your Pick?
27
27
  </h2>
28
28
  <hr>
29
- <p>
29
+ <p>
30
30
  Who were your social good champions this year? Let us know in the comments or nominate them for a Mashable Awards.</p>
31
31
  <hr>
32
- <h3>
33
- The Mashable Awards Gala at Cirque du Soleil Zumanity (Vegas)
32
+ <h3>
33
+ The Mashable Awards Gala at Cirque du Soleil Zumanity (Vegas)
34
34
  </h3>
35
35
  <hr>
36
36
  <p>In partnership with Cirque du Soleil, The Mashable Awards Gala event will bring together the winners and nominees, the Mashable community, partners, media, the marketing community, consumer electronics and technology brands and attendees from the 2011 International CES Convention to Las Vegas on Thursday, January 6, 2011. Together, we will celebrate the winners and the community of the Mashable Awards at the Cirque du Soleil Zumanity stage in the beautiful New York New York Hotel. The event will include acts and performances from our partner Cirque du Soleil Zumanity. In addition, there will be special guest presenters and appearances.</p>
37
- <p>
38
- <strong>Date</strong>: Thursday, January 6th, 2011 (during International CES Convention week)
39
- <strong>Time</strong>: 7:00 &acirc;&euro;&ldquo; 10:00 p.m. PT
40
- <strong>Location</strong>: Cirque du Soleil Zumanity, New York New York Hotel, Las Vegas
41
- <strong>Agenda</strong>: Networking, Open Bars, Acts, Surprises and the Mashable Awards Gala presentations
37
+ <p>
38
+ <strong>Date</strong>: Thursday, January 6th, 2011 (during International CES Convention week)
39
+ <strong>Time</strong>: 7:00 - 10:00 p.m. PT
40
+ <strong>Location</strong>: Cirque du Soleil Zumanity, New York New York Hotel, Las Vegas
41
+ <strong>Agenda</strong>: Networking, Open Bars, Acts, Surprises and the Mashable Awards Gala presentations
42
42
  <strong>Socialize</strong>: <a href="http://www.facebook.com/event.php?eid=123960060989680&amp;ref=ts" target="_blank">Facebook</a>, <a href="http://foursquare.com/venue/8822146" target="_blank">Foursquare</a>, <a href="http://www.meetup.com/mashable/22947/" target="_blank">Meetup</a>, <a href="http://plancast.com/p/27by" target="_blank">Plancast</a>, <a href="http://search.twitter.com/search?q=%23mashableawards" target="_blank">Twitter</a> (Hashtag: #MashableAwards)</p>
43
- <p>
43
+ <p>
44
44
  <strong><em>Mashable Awards Category Sponsor:</em></strong></p>
45
- <p>
46
- <a href="http://ycorpblog.com/"><img src="http://mashable.com/wp-content/uploads/2010/11/yahoo_logo-200x1001.jpg" alt="" title="yahoo_logo-200x100" width="200" height="100" class="alignleft size-full wp-image-442741"></a>Yahoo! is an innovative technology company that operates the largest digital media, content, and communications business in the world. Yahoo! keeps more than half a billion consumers worldwide connected to what matters to them most, and delivers powerful audience solutions to advertisers through its unique combination of Science + Art + Scale. Yahoo! is headquartered in Sunnyvale, California. For more information, visit the company&acirc;&euro;&trade;s blog, <a href="http://ycorpblog.com/" target="_blank">Yodel Anecdotal</a>.</p>
47
- <p>
45
+ <p>
46
+ <a href="http://ycorpblog.com/"><img src="http://mashable.com/wp-content/uploads/2010/11/yahoo_logo-200x1001.jpg" alt="" title="yahoo_logo-200x100" width="200" height="100" class="alignleft size-full wp-image-442741"></a>Yahoo! is an innovative technology company that operates the largest digital media, content, and communications business in the world. Yahoo! keeps more than half a billion consumers worldwide connected to what matters to them most, and delivers powerful audience solutions to advertisers through its unique combination of Science + Art + Scale. Yahoo! is headquartered in Sunnyvale, California. For more information, visit the company's blog, <a href="http://ycorpblog.com/" target="_blank">Yodel Anecdotal</a>.</p>
47
+ <p>
48
48
  <em>Image courtesy of <a rel="nofollow" href="http://www.istockphoto.com/mashableoffer.php">iStockphoto</a>, <a rel="nofollow" href="http://www.istockphoto.com/user_view.php?id=550207">RichVintage</a></em></p>
@@ -0,0 +1,31 @@
1
+ <img src="http://mashable.com/wp-content/uploads/2012/01/Angry-Birds-plush-toys.jpg" alt="" title="Angry Birds plush toys" width="275" height="171" class="alignright size-full wp-image-910465" />Although they're played on small devices, mobile games are becoming a huge deal -- and they're not just confined to smartphones anymore.
2
+
3
+ Games like <em>Doodle Jump</em> and <em>Pocket God</em> were some of the first to expand into multimedia and merchandise markets. And <em>Angry Birds</em> has become ubiquitous enough that retailer Barnes &amp; Noble celebrated <a href="http://www.barnesandnobleinc.com/press_releases/2011_12_8_angry_birds.html">National Angry Birds Day</a> at stores in December 2011, hosting scavenger hunts and merchandise sales.
4
+
5
+ How is it that these games, which sell for less than a cup of coffee, and in some instances are even free, can reach so far? Primarily, it's because they're cheap, and therefore, are able to more easily hook players. A console game that costs 60 times as much will have a higher barrier of entry, and therefore, won't be as likely to achieve mainstream success.
6
+
7
+ <center><strong>SEE ALSO: <a href="http://mashable.com/2011/06/17/angry-birds-products-games/">10 Ways Angry Birds Is Taking Over the World</a></strong></center>
8
+
9
+ A game like <em>Temple Run</em>, which will expand to <a href="http://www.facebook.com/photo.php?fbid=301394146577518&amp;set=a.229085540475046.76637.215459165171017&amp;type=1">Android in February</a>, earns <a href="http://www.gamasutra.com/view/news/39733/Temple_Runs_switch_to_free_more_than_quadrupled_its_revenue.php">7 million players on a daily basis</a>. This exceeds most any other major console or PC title; only an extremely popular franchise like <em>Call of Duty</em> can even come close to that kind of user base. That lower barrier of entry is precisely why more people get hooked, and how games can start to reach mainstream acceptance.
10
+
11
+ Furthermore, people are able to carry smartphone-friendly games in their pockets, purses and backpacks. Often these games accompany people's spare time and commutes. Players develop a positive attachment to mobile games, and are more likely to purchase associated t-shirts, plush toys and even media spinoffs.
12
+
13
+ So what else contributes to a mobile game's success? One of the earliest titles to reach mainstream acceptance, <em>Doodle Jump</em>, was <a href="http://www.pocketgamer.co.uk/r/iPhone/Doodle+Jump/news.asp?c=17379">referenced</a> on <em>The Big Bang Theory</em>, one of the most-watched shows in the U.S. <em>Pocket God</em> achieved popularity through its frequent updates -- weekly, at its peak -- and has introduced an accompanying comic book series and figurines. <a href="http://mashable.com/follow/topics/farmville/"><em>FarmVille</em></a>, a game that started on Facebook before going mobile, has talked about a <a href="http://mashable.com/2011/10/08/farmville-movie/">movie based on the game</a>.
14
+
15
+ But the poster child for mobile games achieving broad cultural reach is <em>Angry Birds</em>. It's the game that celebrities tweet about being addicted to, and the game that continues to top the iOS charts two years after its original release. You'll commonly find <em>Angry Birds</em> merchandise in retail stores -- Rovio even opened up an <a href="http://articles.businessinsider.com/2012-01-02/research/30580646_1_rovio-angry-birds-seasons-ad-impressions/2"><em>Angry Birds</em> retail store</a> in Finland that immediately turned a profit.
16
+
17
+ <img src="http://mashable.com/wp-content/uploads/2012/01/fruit-ninja-kinect-1.jpg" alt="" title="Fruit Ninja Kinect" width="640" height="320" class="aligncenter size-full wp-image-910411" />
18
+
19
+ Although many of these games get started on the iPhone, they are quickly spreading to other platforms, like Android. <em>Angry Birds</em> is also available on computers, and has been used by Google to promote its <a href="http://chrome.angrybirds.com/">Chrome web browser</a>. The game is also <a href="http://mashable.com/2011/01/03/angry-birds-ps/">available on the PSP and PS3</a>, where it has topped sales charts for multiple months. <em>Cut the Rope</em> also expanded to Android, and has been <a href="http://mashable.com/2012/01/10/cut-the-rope-internet-explore/">developed in HTML5 to help promote Internet Explorer</a>. <em>Fruit Ninja</em> made its way to Kinect, and has sold over <a href="http://www.gamasutra.com/view/news/39712/InDepth_Xbox_Live_Arcade_sales_analysis_December_2011.php">739,000 copies</a> to-date.
20
+
21
+ Not surprisingly, becoming involved in the mobile gaming industry can pay off big time. Chillingo, the company that published the original <em>Angry Birds</em> under their Clickgamer label, and later published <em>Cut the Rope</em>, <a href="http://mashable.com/2010/10/20/angry-birds-electronic-arts/">was later bought out by EA for $20 million</a>.
22
+
23
+ <img src="http://mashable.com/wp-content/uploads/2012/01/CutTheRopeComic.jpg" alt="" title="Cut The Rope Comic" width="250" height="" class="alignleft size-full wp-image-910399" />These games are even moving into non-interactive media. <em>Pocket God</em> and <em>Cut The Rope</em> have each introduced a <a href="http://ape-entertainment.com/comics/licensed-properties/pocket-god/">comic book series</a> with <a href="http://ape-entertainment.com/comics/licensed-properties/cut-the-rope/">Ape Entertainment</a>. Animation may be the next step for some of these properties. Rovio has mentioned creating an <a href="http://mashable.com/2011/07/05/angry-birds-movie-2/"><em>Angry Birds</em> cartoon movie</a>; its recent partnership with Dreamworks may be a step toward producing said film. Halfbrick <a href="http://www.gamasutra.com/view/news/35860/Fruit_Ninjas_Halfbrick_Partially_Acquires_Animation_Studio.php"> acquired</a> an Australian animation studio in 2011, which it used to create an animated <a href="http://www.youtube.com/watch?v=Jzxi8nid9BQ">trailer for its game</a>, <em>Jetpack Joyride</em>. Gaming studios that wish to expand their franchises are considering these peripheral markets more and more.
24
+
25
+ What's next for these superstar mobile games? While they continue to dominate the charts, other games are emerging as contenders. Disney's <em>Where's My Water?</em> has earned a solid spot in the top iPhone and Android charts. Disney's established global presence and retail chains are an existing springboard for merchandise sales.
26
+
27
+ <em>Temple Run</em>, developed by the husband-and-wife team at Imangi Studios, could be on the road to app megastardom as well. The game's already massive player base will likely expand in the next few months as the game releases on Android -- and the merchandising possibilities are already there. Evil monkey plush toys? No-brainer.
28
+
29
+ Where would you like to see mobile gaming expand in the future? Do you think some games and developers have a better chance than others? Sound off in the comments below.
30
+
31
+ <hr /><h2>BONUS: 10 Ways <i>Angry Birds</i> Is Taking Over the World</h2><hr />
@@ -23,7 +23,7 @@
23
23
  <p>This model of transparency and accountability has created trust and helped raise more than $20 million for 3,196 projects in the past four years. We hope that its success will influence other non-profits to do the same.</p>
24
24
  <hr>
25
25
  <h2>
26
- What&acirc;&euro;&trade;s Your Pick?
26
+ What's Your Pick?
27
27
  </h2>
28
28
  <hr>
29
29
  <p>
@@ -36,13 +36,13 @@ The Mashable Awards Gala at Cirque du Soleil Zumanity (Vegas)
36
36
  <p>In partnership with Cirque du Soleil, The Mashable Awards Gala event will bring together the winners and nominees, the Mashable community, partners, media, the marketing community, consumer electronics and technology brands and attendees from the 2011 International CES Convention to Las Vegas on Thursday, January 6, 2011. Together, we will celebrate the winners and the community of the Mashable Awards at the Cirque du Soleil Zumanity stage in the beautiful New York New York Hotel. The event will include acts and performances from our partner Cirque du Soleil Zumanity. In addition, there will be special guest presenters and appearances.</p>
37
37
  <p>
38
38
  <strong>Date</strong>: Thursday, January 6th, 2011 (during International CES Convention week)
39
- <strong>Time</strong>: 7:00 &acirc;&euro;&ldquo; 10:00 p.m. PT
39
+ <strong>Time</strong>: 7:00 - 10:00 p.m. PT
40
40
  <strong>Location</strong>: Cirque du Soleil Zumanity, New York New York Hotel, Las Vegas
41
41
  <strong>Agenda</strong>: Networking, Open Bars, Acts, Surprises and the Mashable Awards Gala presentations
42
42
  <strong>Socialize</strong>: <a href="http://www.facebook.com/event.php?eid=123960060989680&amp;ref=ts" target="_blank">Facebook</a>, <a href="http://foursquare.com/venue/8822146" target="_blank">Foursquare</a>, <a href="http://www.meetup.com/mashable/22947/" target="_blank">Meetup</a>, <a href="http://plancast.com/p/27by" target="_blank">Plancast</a>, <a href="http://search.twitter.com/search?q=%23mashableawards" target="_blank">Twitter</a> (Hashtag: #MashableAwards)</p>
43
43
  <p>
44
44
  <strong><em>Mashable Awards Category Sponsor:</em></strong></p>
45
45
  <p>
46
- <a href="http://ycorpblog.com/"><img src="http://mashable.com/wp-content/uploads/2010/11/yahoo_logo-200x1001.jpg" alt="" title="yahoo_logo-200x100" width="200" height="100" class="alignleft size-full wp-image-442741"></a>Yahoo! is an innovative technology company that operates the largest digital media, content, and communications business in the world. Yahoo! keeps more than half a billion consumers worldwide connected to what matters to them most, and delivers powerful audience solutions to advertisers through its unique combination of Science + Art + Scale. Yahoo! is headquartered in Sunnyvale, California. For more information, visit the company&acirc;&euro;&trade;s blog, <a href="http://ycorpblog.com/" target="_blank">Yodel Anecdotal</a>.</p>
46
+ <a href="http://ycorpblog.com/"><img src="http://mashable.com/wp-content/uploads/2010/11/yahoo_logo-200x1001.jpg" alt="" title="yahoo_logo-200x100" width="200" height="100" class="alignleft size-full wp-image-442741"></a>Yahoo! is an innovative technology company that operates the largest digital media, content, and communications business in the world. Yahoo! keeps more than half a billion consumers worldwide connected to what matters to them most, and delivers powerful audience solutions to advertisers through its unique combination of Science + Art + Scale. Yahoo! is headquartered in Sunnyvale, California. For more information, visit the company's blog, <a href="http://ycorpblog.com/" target="_blank">Yodel Anecdotal</a>.</p>
47
47
  <p>
48
48
  <em>Image courtesy of <a rel="nofollow" href="http://www.istockphoto.com/mashableoffer.php">iStockphoto</a>, <a rel="nofollow" href="http://www.istockphoto.com/user_view.php?id=550207">RichVintage</a></em></p>
@@ -0,0 +1,18 @@
1
+ <p><img src="http://mashable.com/wp-content/uploads/2012/01/Angry-Birds-plush-toys.jpg" alt="" title="Angry Birds plush toys" width="275" height="171" class="alignright size-full wp-image-910465" />Although they're played on small devices, mobile games are becoming a huge deal -- and they're not just confined to smartphones anymore. </p>
2
+ <p>Games like <em>Doodle Jump</em> and <em>Pocket God</em> were some of the first to expand into multimedia and merchandise markets. And <em>Angry Birds</em> has become ubiquitous enough that retailer Barnes &amp; Noble celebrated <a href="http://www.barnesandnobleinc.com/press_releases/2011_12_8_angry_birds.html">National Angry Birds Day</a> at stores in December 2011, hosting scavenger hunts and merchandise sales.</p>
3
+ <p>How is it that these games, which sell for less than a cup of coffee, and in some instances are even free, can reach so far? Primarily, it's because they're cheap, and therefore, are able to more easily hook players. A console game that costs 60 times as much will have a higher barrier of entry, and therefore, won't be as likely to achieve mainstream success.</p>
4
+ <p><center><strong>SEE ALSO: <a href="http://mashable.com/2011/06/17/angry-birds-products-games/">10 Ways Angry Birds Is Taking Over the World</a></strong></center></p>
5
+ <p>A game like <em>Temple Run</em>, which will expand to <a href="http://www.facebook.com/photo.php?fbid=301394146577518&amp;set=a.229085540475046.76637.215459165171017&amp;type=1">Android in February</a>, earns <a href="http://www.gamasutra.com/view/news/39733/Temple_Runs_switch_to_free_more_than_quadrupled_its_revenue.php">7 million players on a daily basis</a>. This exceeds most any other major console or PC title; only an extremely popular franchise like <em>Call of Duty</em> can even come close to that kind of user base. That lower barrier of entry is precisely why more people get hooked, and how games can start to reach mainstream acceptance.</p>
6
+ <p>Furthermore, people are able to carry smartphone-friendly games in their pockets, purses and backpacks. Often these games accompany people's spare time and commutes. Players develop a positive attachment to mobile games, and are more likely to purchase associated t-shirts, plush toys and even media spinoffs.</p>
7
+ <p>So what else contributes to a mobile game's success? One of the earliest titles to reach mainstream acceptance, <em>Doodle Jump</em>, was <a href="http://www.pocketgamer.co.uk/r/iPhone/Doodle+Jump/news.asp?c=17379">referenced</a> on <em>The Big Bang Theory</em>, one of the most-watched shows in the U.S. <em>Pocket God</em> achieved popularity through its frequent updates -- weekly, at its peak -- and has introduced an accompanying comic book series and figurines. <a href="http://mashable.com/follow/topics/farmville/"><em>FarmVille</em></a>, a game that started on Facebook before going mobile, has talked about a <a href="http://mashable.com/2011/10/08/farmville-movie/">movie based on the game</a>. </p>
8
+ <p>But the poster child for mobile games achieving broad cultural reach is <em>Angry Birds</em>. It's the game that celebrities tweet about being addicted to, and the game that continues to top the iOS charts two years after its original release. You'll commonly find <em>Angry Birds</em> merchandise in retail stores -- Rovio even opened up an <a href="http://articles.businessinsider.com/2012-01-02/research/30580646_1_rovio-angry-birds-seasons-ad-impressions/2"><em>Angry Birds</em> retail store</a> in Finland that immediately turned a profit.</p>
9
+ <p><img src="http://mashable.com/wp-content/uploads/2012/01/fruit-ninja-kinect-1.jpg" alt="" title="Fruit Ninja Kinect" width="640" height="320" class="aligncenter size-full wp-image-910411" /></p>
10
+ <p>Although many of these games get started on the iPhone, they are quickly spreading to other platforms, like Android. <em>Angry Birds</em> is also available on computers, and has been used by Google to promote its <a href="http://chrome.angrybirds.com/">Chrome web browser</a>. The game is also <a href="http://mashable.com/2011/01/03/angry-birds-ps/">available on the PSP and PS3</a>, where it has topped sales charts for multiple months. <em>Cut the Rope</em> also expanded to Android, and has been <a href="http://mashable.com/2012/01/10/cut-the-rope-internet-explore/">developed in HTML5 to help promote Internet Explorer</a>. <em>Fruit Ninja</em> made its way to Kinect, and has sold over <a href="http://www.gamasutra.com/view/news/39712/InDepth_Xbox_Live_Arcade_sales_analysis_December_2011.php">739,000 copies</a> to-date.</p>
11
+ <p>Not surprisingly, becoming involved in the mobile gaming industry can pay off big time. Chillingo, the company that published the original <em>Angry Birds</em> under their Clickgamer label, and later published <em>Cut the Rope</em>, <a href="http://mashable.com/2010/10/20/angry-birds-electronic-arts/">was later bought out by EA for $20 million</a>.</p>
12
+ <p><img src="http://mashable.com/wp-content/uploads/2012/01/CutTheRopeComic.jpg" alt="" title="Cut The Rope Comic" width="250" height="" class="alignleft size-full wp-image-910399" />These games are even moving into non-interactive media. <em>Pocket God</em> and <em>Cut The Rope</em> have each introduced a <a href="http://ape-entertainment.com/comics/licensed-properties/pocket-god/">comic book series</a> with <a href="http://ape-entertainment.com/comics/licensed-properties/cut-the-rope/">Ape Entertainment</a>. Animation may be the next step for some of these properties. Rovio has mentioned creating an <a href="http://mashable.com/2011/07/05/angry-birds-movie-2/"><em>Angry Birds</em> cartoon movie</a>; its recent partnership with Dreamworks may be a step toward producing said film. Halfbrick <a href="http://www.gamasutra.com/view/news/35860/Fruit_Ninjas_Halfbrick_Partially_Acquires_Animation_Studio.php"> acquired</a> an Australian animation studio in 2011, which it used to create an animated <a href="http://www.youtube.com/watch?v=Jzxi8nid9BQ">trailer for its game</a>, <em>Jetpack Joyride</em>. Gaming studios that wish to expand their franchises are considering these peripheral markets more and more. </p>
13
+ <p>What's next for these superstar mobile games? While they continue to dominate the charts, other games are emerging as contenders. Disney's <em>Where's My Water?</em> has earned a solid spot in the top iPhone and Android charts. Disney's established global presence and retail chains are an existing springboard for merchandise sales. </p>
14
+ <p><em>Temple Run</em>, developed by the husband-and-wife team at Imangi Studios, could be on the road to app megastardom as well. The game's already massive player base will likely expand in the next few months as the game releases on Android -- and the merchandising possibilities are already there. Evil monkey plush toys? No-brainer.</p>
15
+ <p>Where would you like to see mobile gaming expand in the future? Do you think some games and developers have a better chance than others? Sound off in the comments below.</p>
16
+ <hr />
17
+ <h2>BONUS: 10 Ways <i>Angry Birds</i> Is Taking Over the World</h2>
18
+ <hr />
@@ -120,11 +120,20 @@ EOF
120
120
  @out = File.expand_path(File.join(__FILE__, "..", "..", "data", "out"))
121
121
  end
122
122
 
123
+ def clean_data(data)
124
+ data.gsub(/[\r\n\s]+/, " ").
125
+ gsub(/>/, ">\n").
126
+ gsub(" />", ">").
127
+ split(/\n/).
128
+ map(&:strip).
129
+ join("\n").strip
130
+ end
131
+
123
132
  def test_datafile(file)
124
133
  data_in = File.read(file)
125
134
  control = File.read(File.join(@out, File.basename(file)))
126
135
  out = Wraptext::Parser.new(data_in).to_html
127
- out.strip.gsub(/\s+/, " ").gsub(/>/, ">\n").should == control.strip.gsub(/\s+/, " ").gsub(/>/, ">\n")
136
+ clean_data(out).should == clean_data(control)
128
137
  end
129
138
 
130
139
  Dir.glob( File.expand_path(File.join(__FILE__, "..", "..", "data", "in", "*")) ).each do |file|
@@ -133,4 +142,22 @@ EOF
133
142
  end
134
143
  end
135
144
  end
145
+
146
+ context "Given a p with em inside it" do
147
+ doc = <<-EOF
148
+ <p>
149
+ This is some <em>emphasized</em> text
150
+
151
+ And here is <i>another</i> line
152
+ </p>
153
+ EOF
154
+
155
+ expects = <<-EOF
156
+ <p>
157
+ This is some <em>emphasized</em> text</p>
158
+ <p> And here is <i>another</i> line
159
+ </p>
160
+ EOF
161
+ Wraptext::Parser.new(doc).to_html.should == expects.strip
162
+ end
136
163
  end
data/wraptext.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
12
  gem.name = "wraptext"
13
13
  gem.require_paths = ["lib"]
14
- gem.version = "0.1.1"
14
+ gem.version = "0.1.2"
15
15
 
16
16
  gem.add_dependency('nokogiri')
17
17
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wraptext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Heald
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-30 00:00:00 Z
18
+ date: 2012-01-31 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -52,9 +52,11 @@ files:
52
52
  - spec/data/in/4ced9bc198db7477220005c3.txt
53
53
  - spec/data/in/4ced9bf198db7477220006f1.txt
54
54
  - spec/data/in/4ced9bf798db74772200070f.txt
55
+ - spec/data/in/mobile-games.txt
55
56
  - spec/data/out/4ced9bc198db7477220005c3.txt
56
57
  - spec/data/out/4ced9bf198db7477220006f1.txt
57
58
  - spec/data/out/4ced9bf798db74772200070f.txt
59
+ - spec/data/out/mobile-games.txt
58
60
  - spec/data/wordpress_autop.php
59
61
  - spec/spec_helper.rb
60
62
  - spec/wraptext/parser_spec.rb
@@ -97,9 +99,11 @@ test_files:
97
99
  - spec/data/in/4ced9bc198db7477220005c3.txt
98
100
  - spec/data/in/4ced9bf198db7477220006f1.txt
99
101
  - spec/data/in/4ced9bf798db74772200070f.txt
102
+ - spec/data/in/mobile-games.txt
100
103
  - spec/data/out/4ced9bc198db7477220005c3.txt
101
104
  - spec/data/out/4ced9bf198db7477220006f1.txt
102
105
  - spec/data/out/4ced9bf798db74772200070f.txt
106
+ - spec/data/out/mobile-games.txt
103
107
  - spec/data/wordpress_autop.php
104
108
  - spec/spec_helper.rb
105
109
  - spec/wraptext/parser_spec.rb