opml2html 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/opml2html/outline.rb +16 -4
- data/lib/opml2html/renderer.rb +13 -3
- data/lib/opml2html/traverser.rb +4 -4
- data/lib/opml2html/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e0131ae0abb115a15cafbf60050e6ee4fff9acd3a84d00d35b0d742f4bccdb2
|
4
|
+
data.tar.gz: 6d6581e206aa9a10a6b7136bf92256db3a554ec21f5c29123250d383b2337edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c51c90e04f57ae7e3b7c0193e51a38dd3c4cc697b211c4bc891c238085484c3eeb7b5aa60a77f787c5351edcd29a1dc08b62c4423282393601b78b8da8275c4
|
7
|
+
data.tar.gz: a9ab4adccc8fcfafb04b4c562fe65fa11d62defc0a51e96a1f0ca22a54b448cab06d110d960eaeffdf0db7b6a331acb6cbf846eb8994471a2f582099322defbe
|
data/CHANGELOG.md
CHANGED
data/lib/opml2html/outline.rb
CHANGED
@@ -11,13 +11,15 @@ module OPML2HTML
|
|
11
11
|
keys.each do |key|
|
12
12
|
case key
|
13
13
|
in :text
|
14
|
-
result[:text] = text
|
14
|
+
result[:text] = (text or next)
|
15
15
|
in :created
|
16
|
-
result[:created] = created
|
16
|
+
result[:created] = (created or next)
|
17
17
|
in :children
|
18
|
-
result[:children] = children
|
18
|
+
result[:children] = (children or next)
|
19
19
|
in :xml_url
|
20
|
-
result[:xml_url] = xml_url
|
20
|
+
result[:xml_url] = (xml_url or next)
|
21
|
+
in :description
|
22
|
+
result[:description] = description
|
21
23
|
end
|
22
24
|
end
|
23
25
|
result
|
@@ -51,6 +53,16 @@ module OPML2HTML
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
56
|
+
def description
|
57
|
+
@description || @empty_description and return @description
|
58
|
+
if attributes in [*, Attr[name: "description", value:], *]
|
59
|
+
@description = value
|
60
|
+
else
|
61
|
+
@empty_description = true
|
62
|
+
return
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
54
66
|
def attributes
|
55
67
|
@attributes and return @attributes
|
56
68
|
@node => Element[attributes:]
|
data/lib/opml2html/renderer.rb
CHANGED
@@ -42,10 +42,15 @@ module OPML2HTML
|
|
42
42
|
@document.main.add_child(@document.metadata)
|
43
43
|
end
|
44
44
|
|
45
|
-
def body_outline_heading(value)
|
46
|
-
heading = @document.create_element("
|
45
|
+
def body_outline_heading(value, description:, level:)
|
46
|
+
heading = @document.create_element("h#{level + 1}")
|
47
47
|
heading.add_child(value)
|
48
48
|
@document.main.add_child(heading)
|
49
|
+
if description
|
50
|
+
desc = @document.create_element("p")
|
51
|
+
desc.content = description
|
52
|
+
@document.main.add_child(desc)
|
53
|
+
end
|
49
54
|
end
|
50
55
|
|
51
56
|
def body_outline_text(value)
|
@@ -54,12 +59,17 @@ module OPML2HTML
|
|
54
59
|
@document.main.add_child(par)
|
55
60
|
end
|
56
61
|
|
57
|
-
def body_outline_rss(fragment, xml_url)
|
62
|
+
def body_outline_rss(fragment, xml_url, description: nil)
|
58
63
|
anchor = @document.create_element("a")
|
59
64
|
anchor.add_child(fragment)
|
60
65
|
anchor["href"] = xml_url
|
61
66
|
par = @document.create_element("p")
|
62
67
|
par.add_child(anchor)
|
68
|
+
if description
|
69
|
+
desc = @document.create_element("p")
|
70
|
+
desc.content = description
|
71
|
+
par.add_child(desc)
|
72
|
+
end
|
63
73
|
@document.main.add_child(par)
|
64
74
|
end
|
65
75
|
|
data/lib/opml2html/traverser.rb
CHANGED
@@ -75,15 +75,15 @@ module OPML2HTML
|
|
75
75
|
|
76
76
|
def parse_outline(node, level:)
|
77
77
|
case Outline.new(node)
|
78
|
-
in text:, xml_url:, children: []
|
78
|
+
in text:, xml_url:, description:, children: []
|
79
79
|
value = DocumentFragment.parse(text)
|
80
|
-
@hook.body_outline_rss(value, xml_url)
|
80
|
+
@hook.body_outline_rss(value, xml_url, description:)
|
81
81
|
in text:, children: []
|
82
82
|
value = DocumentFragment.parse(text)
|
83
83
|
@hook.body_outline_text(value)
|
84
|
-
in text:, children:
|
84
|
+
in text:, children:, description:
|
85
85
|
value = DocumentFragment.parse(text)
|
86
|
-
@hook.body_outline_heading(value)
|
86
|
+
@hook.body_outline_heading(value, description:, level:)
|
87
87
|
children.each do |child|
|
88
88
|
(child in Text) and next
|
89
89
|
parse_outline(child, level: level + 1)
|
data/lib/opml2html/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opml2html
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gemmaro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|