swordfish 0.0.2 → 0.0.3

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDQyYjhkZjNiNTRjNTE3ZWRlYmFmNWMzOGI5Nzg0OTU3MjNhMWRkOQ==
4
+ MjlkNGYxMWRlZmZkMzVlYzI2YWYzNjA2MTA0MzU0MWIyZTY5ZDdhYQ==
5
5
  data.tar.gz: !binary |-
6
- YjA5YWZmZDMyMWY4NzgxMmQ1MWVhNTU4YmQ0MDA4YmU4NDUyOTRhNg==
6
+ Y2E2MDA5YzFiODYzNDhkMTdkYzNkNWFlNTM4NGVhNGU0YWI5NzIwYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTg0NzAwNTFjMzhhNDYzNWY3MjgyMzQ3MDdkMDVhNjE1NWYzMTc0ZjFhZWJj
10
- YzM1M2YzNzQ4YjEyZDg2YTQwOWY3OGJjY2JhZmE4MGUyZGQ1NmEwNzkwMDk1
11
- N2FjMzQ2MjRjNDcwYWY3YmVmODhkMGNhMjEwMTc2OTRmYzFmODY=
9
+ NWE3MGJmZjc2N2M2MDQ4ZjMxYzNlMGZjY2ZjZGEyNTIyODZkYjQ1NTUwMWNi
10
+ OGZhODAyODI0NDJlZmZmM2M3NDc5YzZiZjg1YmNkNDA1ZGY3YzVkMzkyZmVl
11
+ YWNhMWI0YzU4MzA1NTQ3ZDQ5MTE0YWIzN2Y4ZGEyMDQzOTUxN2M=
12
12
  data.tar.gz: !binary |-
13
- NzRhNWRiOWFjMzAwNGNlZjQ0OTZiZWM3MDYwM2NkYzNlMDQ0YWNjYTk0MGJk
14
- Zjk3NmZhYzA0NmVhYWJjYjFkZTg0MDY0OGY1MzFmMjM5MTE3ZjgwNGU5NTVk
15
- NmEwZWZiOGU3MGFkMTk3MTZjOGJmMGZlZGQ4YjMzMjBjNjkyM2M=
13
+ YjQ4OGY2ZjNmNWVlMTI5NzhjYjIzOTc1NzJlNWMzYWQ4NWZmNzM1Yzg1NTY1
14
+ OWI4ZDhmYmZmMGNjZTA1MWI1OTA1MjA1M2RhYjc2MTZjNjFiMjFjMzkyMGYx
15
+ MGQwMGI3YjI5ZDljMjI3MWZjZGYwYzNlN2UxMzBiNmMwMWI3YzY=
@@ -1,3 +1,4 @@
1
+ require 'cgi'
1
2
  require 'swordfish/stylesheet'
2
3
  require 'swordfish/nodes/base'
3
4
  require 'swordfish/nodes/text'
@@ -7,7 +7,8 @@ module Swordfish
7
7
  attr_accessor :href
8
8
 
9
9
  def to_html
10
- "<a href='#{@href}'>#{@children.map(&:to_html).join}</a>"
10
+ @href ||= ""
11
+ "<a href=\"#{CGI::escape(@href)}\">#{@children.map(&:to_html).join}</a>"
11
12
  end
12
13
 
13
14
  end
@@ -11,6 +11,7 @@ module Swordfish
11
11
  attr_accessor :original_name
12
12
  # @path holds a new name for the image that must be assigned explicitly
13
13
  attr_accessor :path
14
+ attr_accessor :caption
14
15
 
15
16
  # Override Base append because an image node should never have children
16
17
  def append(node)
@@ -18,7 +19,8 @@ module Swordfish
18
19
  end
19
20
 
20
21
  def to_html
21
- "<img src='#{@path ? @path : @original_name}'>"
22
+ @caption ||= ""
23
+ "<img src=\"#{CGI::escape(@path ? @path : @original_name)}\" alt=\"#{CGI::escapeHTML(@caption)}\" title=\"#{CGI::escapeHTML(@caption)}\" />"
22
24
  end
23
25
 
24
26
  end
@@ -7,6 +7,9 @@ module Swordfish
7
7
  def to_html
8
8
  if @content
9
9
  "<p>#{@content}</p>"
10
+ elsif @children.length == 1 && @children[0].is_a?(Swordfish::Node::Image)
11
+ # If the only child is an image, don't bother putting it in a P tag
12
+ @children.map(&:to_html).join
10
13
  else
11
14
  text = @children.map(&:to_html).join
12
15
  "<p>#{text}</p>" unless text.length.zero?
@@ -10,7 +10,8 @@ module Swordfish
10
10
  end
11
11
 
12
12
  def to_html
13
- html = @content
13
+ @content ||= ""
14
+ html = CGI::escapeHTML(@content)
14
15
  html = "<i>#{html}</i>" if @style.italic?
15
16
  html = "<b>#{html}</b>" if @style.bold?
16
17
  html = "<u>#{html}</u>" if @style.underline?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swordfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Posthumus