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 +8 -8
- data/lib/swordfish/document.rb +1 -0
- data/lib/swordfish/nodes/hyperlink.rb +2 -1
- data/lib/swordfish/nodes/image.rb +3 -1
- data/lib/swordfish/nodes/paragraph.rb +3 -0
- data/lib/swordfish/nodes/text.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjlkNGYxMWRlZmZkMzVlYzI2YWYzNjA2MTA0MzU0MWIyZTY5ZDdhYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2E2MDA5YzFiODYzNDhkMTdkYzNkNWFlNTM4NGVhNGU0YWI5NzIwYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NWE3MGJmZjc2N2M2MDQ4ZjMxYzNlMGZjY2ZjZGEyNTIyODZkYjQ1NTUwMWNi
|
10
|
+
OGZhODAyODI0NDJlZmZmM2M3NDc5YzZiZjg1YmNkNDA1ZGY3YzVkMzkyZmVl
|
11
|
+
YWNhMWI0YzU4MzA1NTQ3ZDQ5MTE0YWIzN2Y4ZGEyMDQzOTUxN2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjQ4OGY2ZjNmNWVlMTI5NzhjYjIzOTc1NzJlNWMzYWQ4NWZmNzM1Yzg1NTY1
|
14
|
+
OWI4ZDhmYmZmMGNjZTA1MWI1OTA1MjA1M2RhYjc2MTZjNjFiMjFjMzkyMGYx
|
15
|
+
MGQwMGI3YjI5ZDljMjI3MWZjZGYwYzNlN2UxMzBiNmMwMWI3YzY=
|
data/lib/swordfish/document.rb
CHANGED
@@ -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
|
-
|
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?
|
data/lib/swordfish/nodes/text.rb
CHANGED