gamefic 1.3.0 → 1.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9653029c10eea5877023b0f33166f04097390a0
4
- data.tar.gz: 7fc2ed5e68a3e308524abb5f2d273fbc69ea18bd
3
+ metadata.gz: edb52e99ac3e2c2398b119a6998022c6d06f9b4f
4
+ data.tar.gz: 6b621e12bfb8aaf4f284a599b5b23cdae55477cd
5
5
  SHA512:
6
- metadata.gz: 55f967f633d6054a4b9f3700938a0f0eb81a877957f3aa11c09119d102ddaac71fdb566ac9ffa5a9daddceec22aa523228c0271707d8a60ce71629618d666517
7
- data.tar.gz: 857869d33e31abb8ca303b070210e626e7d4e0572416a71a70d2411e8878960100a2543d4c3887bad2cdd21cf4fe7bdf5135bebb363652551f1736ed69d387bd
6
+ metadata.gz: e413d5ad81d17a7d6d6e77410e039a822dbc98d4516fb3832e209a557a8678c255a6f22ff413f8050a1298011423cb5927cf8d410d266befa32aec3cbf2e9dfc
7
+ data.tar.gz: 3ba4d089d93592709df8f78531a7c8ec7ae2952abde0e6b8db5dab2357b613bc58e64455ba9d1b72321d48aef8350832e97db2401d93853bbf8d0c75bb277a4a
@@ -36,6 +36,7 @@ module Gamefic
36
36
  end
37
37
  module Extra
38
38
  BLOCK = Nonstandard.new("block")
39
+ PRE = Nonstandard.new("pre")
39
40
  HREF = Nonstandard.new("href")
40
41
  IMAGE = Nonstandard.new("image")
41
42
  SRC = Nonstandard.new("src")
@@ -74,11 +74,11 @@ module Gamefic
74
74
  if @buffer_stack > 0
75
75
  @buffer += message
76
76
  else
77
- message = "<p>#{message}</p>"
77
+ message = "<p>#{message.strip}</p>"
78
78
  # This method uses String#gsub instead of String#gsub! for
79
79
  # compatibility with Opal.
80
- message = message.gsub(/\n\n/, '</p><p>')
81
- message = message.gsub(/\n/, '<br/>')
80
+ message = message.gsub(/[ \t]*\n[ \t]*\n[ \t]*/, '</p><p>')
81
+ message = message.gsub(/[ \t]*\n[ \t]*/, ' ')
82
82
  user.stream.send message
83
83
  end
84
84
  end
@@ -89,7 +89,7 @@ module Gamefic
89
89
  #
90
90
  # @param message [String]
91
91
  def stream(message)
92
- user.stream.send message if !user.nil?
92
+ user.stream.send message.strip if !user.nil?
93
93
  end
94
94
 
95
95
  def destroy
@@ -88,14 +88,13 @@ module Gamefic
88
88
  return if data.strip == ''
89
89
  output = ''
90
90
  begin
91
- doc = Html.parse("<body>#{data}</body>")
91
+ doc = Html.parse("<body>#{data.strip}</body>")
92
92
  format_recursively doc
93
93
  texts = REXML::XPath.match(doc, './/text()')
94
94
  output = texts.join('').gsub(/&apos;/, "'").gsub(/&quot;/, '"').gsub(/&lt;/, '<').gsub(/&gt;/, '>')
95
95
  output += Ansi.graphics_mode(Attribute::NORMAL)
96
96
  output = Html::decode(output)
97
97
  rescue REXML::ParseException => e
98
- puts e.inspect
99
98
  output = Html.encode(data) + "\n\n"
100
99
  end
101
100
  output.gsub!(/(\n\n)+/, "\n\n")
@@ -150,8 +149,10 @@ module Gamefic
150
149
  formats.push [Extra::LINE]
151
150
  when 'img'
152
151
  formats.push [Extra::IGNORED]
153
- when 'p', 'ol', 'ul'
152
+ when 'body', 'p', 'ol', 'ul'
154
153
  formats.push Extra::BLOCK
154
+ when 'pre'
155
+ formats.push [Extra::BLOCK, Extra::PRE]
155
156
  when 'nav'
156
157
  formats.push Extra::BLOCK
157
158
  when 'h1', 'h2', 'h3', 'h4', 'h5'
@@ -184,6 +185,13 @@ module Gamefic
184
185
  element.add_text "#{Ansi.graphics_mode(*stack)}"
185
186
  end
186
187
  end
188
+ if has_code?(stack.last, Extra::BLOCK) and !has_code?(stack.last, Extra::PRE)
189
+ element.texts.first.value.lstrip! unless element.texts.first.nil?
190
+ element.texts.last.value.rstrip! unless element.texts.last.nil?
191
+ element.texts.each { |t|
192
+ t.value = t.value.gsub(/ +/, ' ').strip
193
+ }
194
+ end
187
195
  if has_code?(stack.last, Extra::BLOCK)
188
196
  element.add_text("\n\n")
189
197
  elsif has_code?(stack.last, Extra::LINE)
@@ -1,3 +1,3 @@
1
1
  module Gamefic
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gamefic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-26 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor